Submission #1073891


Source Code Expand

import java.util.*;

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[] b = new long[n];
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextLong();
			b[i] = sc.nextLong();
		}
		long s = 0;
		for (int i = n - 1; i >= 0; --i) {
			if ((a[i] + s) % b[i] == 0)
				continue;
			s += b[i] - (a[i] + s) % b[i];
		}
		System.out.println(s);
	}
}

Submission Info

Submission Time
Task A - Multiple Array
User fortoobye
Language Java8 (OpenJDK 1.8.0)
Score 300
Code Size 469 Byte
Status AC
Exec Time 670 ms
Memory 72840 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 18
Set Name Test Cases
Sample s1.txt, s2.txt
All 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, s1.txt, s2.txt
Case Name Status Exec Time Memory
01.txt AC 647 ms 72840 KB
02.txt AC 642 ms 50300 KB
03.txt AC 635 ms 50296 KB
04.txt AC 624 ms 50504 KB
05.txt AC 642 ms 50476 KB
06.txt AC 642 ms 50236 KB
07.txt AC 627 ms 50952 KB
08.txt AC 652 ms 50128 KB
09.txt AC 615 ms 66452 KB
10.txt AC 670 ms 50592 KB
11.txt AC 555 ms 50696 KB
12.txt AC 571 ms 63972 KB
13.txt AC 567 ms 50392 KB
14.txt AC 656 ms 50336 KB
15.txt AC 128 ms 9556 KB
16.txt AC 126 ms 9680 KB
s1.txt AC 127 ms 9676 KB
s2.txt AC 127 ms 9676 KB