Submission #3235509


Source Code Expand


import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            int N = sc.nextInt();
            long t = 1;
            long a = 1;

            for (int i = 0; i < N; i++) {
                long T = sc.nextLong();
                long A = sc.nextLong();

                long tx = -1;
                long ax = -1;

                for (int ti = 0; ti < T; ti++) {
                    if ( (t + ti) % T == 0 ) {
                        tx = t + ti;
                        ax = (tx / T) * A;
                    }
                }

                long ty = -1;
                long ay = -1;

                for (int ai = 0; ai < A; ai++) {
                    if ( (a + ai) % A == 0 ) {
                        ay = a + ai;
                        ty = (ay / A) * T;
                    }
                }

                long tn = -1;
                long an = -1;

                if ( tx >= t && ax >= a ) {
                    tn = tx;
                    an = ax;
                }

                if ( tn == -1 || ty >= t && ay >= a && (ty + ay) < (tn + an) ) {
                    tn = ty;
                    an = ay;
                }

                t = tn;
                a = an;

                if ( t == -1 ) {
                    int zero = 1 / 2;
                    int hoge = 10 / zero;
                }
            }

            System.out.println(t + a);
        }
    }
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User Respect2D
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 1589 Byte
Status AC
Exec Time 183 ms
Memory 24944 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 15
Set Name Test Cases
Sample 0_000.txt, 0_001.txt, 0_002.txt
All 0_000.txt, 0_001.txt, 0_002.txt, 1_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt
Case Name Status Exec Time Memory
0_000.txt AC 97 ms 17748 KB
0_001.txt AC 96 ms 17876 KB
0_002.txt AC 96 ms 19796 KB
1_003.txt AC 96 ms 19284 KB
1_004.txt AC 144 ms 24560 KB
1_005.txt AC 109 ms 19796 KB
1_006.txt AC 134 ms 24584 KB
1_007.txt AC 111 ms 21716 KB
1_008.txt AC 103 ms 21972 KB
1_009.txt AC 103 ms 19284 KB
1_010.txt AC 108 ms 19284 KB
1_011.txt AC 102 ms 20948 KB
1_012.txt AC 114 ms 19284 KB
1_013.txt AC 147 ms 24944 KB
1_014.txt AC 183 ms 23124 KB