Submission #1352375
Source Code Expand
import java.io.IOException; import java.util.Scanner; public class Main { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); int n = in.nextInt(); int[] a = new int[n]; int[] b = new int[n]; for(int i=0; i<n; i++){ a[i] = in.nextInt(); b[i] = in.nextInt(); } long plus = 0; long temp = 0; for(int i=n-1; i>=0; i--){ temp = a[i]+plus; if(temp%b[i]!=0){ plus += b[i]*(temp/b[i]+1) - temp; } } System.out.println(plus); } }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | unirita51 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 549 Byte |
Status | AC |
Exec Time | 596 ms |
Memory | 77316 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 | 582 ms | 65024 KB |
02.txt | AC | 588 ms | 61824 KB |
03.txt | AC | 581 ms | 63084 KB |
04.txt | AC | 562 ms | 62756 KB |
05.txt | AC | 559 ms | 62820 KB |
06.txt | AC | 570 ms | 63324 KB |
07.txt | AC | 542 ms | 62984 KB |
08.txt | AC | 596 ms | 62480 KB |
09.txt | AC | 567 ms | 61716 KB |
10.txt | AC | 583 ms | 64688 KB |
11.txt | AC | 535 ms | 64052 KB |
12.txt | AC | 462 ms | 77316 KB |
13.txt | AC | 517 ms | 65568 KB |
14.txt | AC | 548 ms | 65028 KB |
15.txt | AC | 96 ms | 19668 KB |
16.txt | AC | 93 ms | 18388 KB |
s1.txt | AC | 93 ms | 18636 KB |
s2.txt | AC | 95 ms | 23252 KB |