Submission #928867


Source Code Expand

Copy
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		long[] t = new long[n];
		long x = 1;
		for(int i=0; i<n; i++){
			a[i] = sc.nextLong();
			t[i] = sc.nextLong();
		}
		for(int i=1; i<n; i++){
			long xa, xt;
			if(x*a[i-1]%a[i] == 0){
				xa = x*a[i-1]/a[i];
			}else{
				xa = x*a[i-1]/a[i]+1;
			}

			if(x*t[i-1]%t[i]==0){
				xt = x*t[i-1]/t[i];
			}else{
				xt = x*t[i-1]/t[i]+1;
			}
			x = xa > xt ? xa : xt;
		}

		System.out.println(x * (a[n-1]+t[n-1]));
	}

}

Submission Info

Submission Time
Task C - AtCoDeer and Election Report
User yukidaruma6
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 636 Byte
Status
Exec Time 181 ms
Memory 13528 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 0_000.txt, 0_001.txt, 0_002.txt
All 300 / 300 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 127 ms 9676 KB
0_001.txt 127 ms 9680 KB
0_002.txt 127 ms 9680 KB
1_003.txt 126 ms 9684 KB
1_004.txt 181 ms 13308 KB
1_005.txt 146 ms 10576 KB
1_006.txt 167 ms 11528 KB
1_007.txt 147 ms 10696 KB
1_008.txt 145 ms 9804 KB
1_009.txt 133 ms 9800 KB
1_010.txt 133 ms 9680 KB
1_011.txt 132 ms 9804 KB
1_012.txt 135 ms 9924 KB
1_013.txt 179 ms 13528 KB
1_014.txt 176 ms 13084 KB