Submission #1481811


Source Code Expand

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        long t_pre = 1, a_pre = 1;
        for(int i=0; i<n; i++){
            String[] str = br.readLine().split(" ");
            long t = Integer.parseInt(str[0]);
            long a = Integer.parseInt(str[1]);

            long rate = Math.max(t_pre/t + (t_pre%t==0 ?0:1), a_pre/a + (a_pre%a==0?0:1));
            t_pre = rate * t;
            a_pre = rate * a;
        }
        System.out.println(t_pre + a_pre);
    }
}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User kengo0o0
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 761 Byte
Status AC
Exec Time 105 ms
Memory 22996 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 73 ms 20564 KB
0_001.txt AC 68 ms 19028 KB
0_002.txt AC 67 ms 19156 KB
1_003.txt AC 67 ms 20948 KB
1_004.txt AC 89 ms 20180 KB
1_005.txt AC 71 ms 17748 KB
1_006.txt AC 73 ms 22996 KB
1_007.txt AC 79 ms 20564 KB
1_008.txt AC 67 ms 19412 KB
1_009.txt AC 71 ms 19156 KB
1_010.txt AC 72 ms 19156 KB
1_011.txt AC 68 ms 19796 KB
1_012.txt AC 77 ms 19412 KB
1_013.txt AC 105 ms 20052 KB
1_014.txt AC 85 ms 18260 KB