Submission #1350947
Source Code Expand
import java.util.Scanner; public class Main { static Scanner in = new Scanner(System.in); public static void main(String[] args){ int n = in.nextInt(); long[] a = new long[n], b = new long[n]; for(int i = 0; i < n; i++){ a[i] = in.nextLong(); b[i] = in.nextLong(); } long sum = 0; for(int i = n - 1; i > -1; i--){ if(((a[i] + sum) % b[i]) != 0){ sum += b[i] - ((a[i] + sum) % b[i]); } } System.out.println(sum); } }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | mosmos21 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 473 Byte |
Status | AC |
Exec Time | 591 ms |
Memory | 65464 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 | 574 ms | 65128 KB |
02.txt | AC | 566 ms | 65184 KB |
03.txt | AC | 565 ms | 64764 KB |
04.txt | AC | 591 ms | 63352 KB |
05.txt | AC | 557 ms | 62944 KB |
06.txt | AC | 567 ms | 63404 KB |
07.txt | AC | 536 ms | 64544 KB |
08.txt | AC | 568 ms | 63216 KB |
09.txt | AC | 545 ms | 63968 KB |
10.txt | AC | 555 ms | 63352 KB |
11.txt | AC | 528 ms | 63708 KB |
12.txt | AC | 476 ms | 63016 KB |
13.txt | AC | 530 ms | 65464 KB |
14.txt | AC | 574 ms | 63816 KB |
15.txt | AC | 93 ms | 19924 KB |
16.txt | AC | 93 ms | 20688 KB |
s1.txt | AC | 92 ms | 19156 KB |
s2.txt | AC | 93 ms | 21844 KB |