Submission #5494616
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(); int A[] = new int[N]; int B[] = new int[N]; for(int i = 0; i < N; i++) { A[i] = sc.nextInt(); B[i] = sc.nextInt(); } int ans = 0; for(int i = N - 1; i >= 0; i--) { int cnt = 0; if(A[i] % B[i] > 0) { cnt = B[i] - (A[i] % B[i]); } else if(A[i] % B[i] < 0) { cnt = A[i] % B[i]; } ans += cnt; for(int j = i - 1; j >= 0; j--) { A[j] += cnt; } } System.out.println(ans); } }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | YK0809 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 601 Byte |
Status | WA |
Exec Time | 1393 ms |
Memory | 87000 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 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 | WA | 1374 ms | 63888 KB |
02.txt | WA | 1355 ms | 62560 KB |
03.txt | WA | 1379 ms | 87000 KB |
04.txt | WA | 1373 ms | 61436 KB |
05.txt | WA | 1385 ms | 64972 KB |
06.txt | WA | 1393 ms | 61080 KB |
07.txt | AC | 1350 ms | 64432 KB |
08.txt | WA | 1352 ms | 64944 KB |
09.txt | AC | 1318 ms | 62532 KB |
10.txt | WA | 1378 ms | 64284 KB |
11.txt | AC | 1325 ms | 64212 KB |
12.txt | AC | 1293 ms | 63772 KB |
13.txt | WA | 1309 ms | 64544 KB |
14.txt | AC | 1382 ms | 85740 KB |
15.txt | AC | 92 ms | 19156 KB |
16.txt | AC | 91 ms | 19924 KB |
s1.txt | AC | 94 ms | 19540 KB |
s2.txt | AC | 92 ms | 19284 KB |