Submission #1073392
Source Code Expand
import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { int N = sc.nextInt(); long[] A = new long[N]; long[] B = new long[N]; for (int i = 0; i < N; i++) { A[i] = Long.parseLong(sc.next()); B[i] = Long.parseLong(sc.next()); } long ans = 0; for (int i = N - 1; i >= 0; i--) { long cur = A[i] + ans; ans += (cur + B[i] - 1) / B[i] * B[i] - cur; } System.out.println(ans); } }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | tomerun |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 540 Byte |
Status | AC |
Exec Time | 561 ms |
Memory | 36284 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 300 / 300 | ||||
Status |
|
|
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 | 534 ms | 35308 KB |
02.txt | AC | 506 ms | 35060 KB |
03.txt | AC | 561 ms | 35764 KB |
04.txt | AC | 529 ms | 35552 KB |
05.txt | AC | 554 ms | 35528 KB |
06.txt | AC | 505 ms | 35228 KB |
07.txt | AC | 502 ms | 36284 KB |
08.txt | AC | 504 ms | 35836 KB |
09.txt | AC | 549 ms | 35832 KB |
10.txt | AC | 490 ms | 35684 KB |
11.txt | AC | 474 ms | 34676 KB |
12.txt | AC | 489 ms | 35268 KB |
13.txt | AC | 472 ms | 35884 KB |
14.txt | AC | 516 ms | 35856 KB |
15.txt | AC | 121 ms | 9672 KB |
16.txt | AC | 120 ms | 9668 KB |
s1.txt | AC | 119 ms | 9552 KB |
s2.txt | AC | 120 ms | 9668 KB |