Submission #5415982
Source Code Expand
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner stdIn=new Scanner(System.in); int N=stdIn.nextInt(); long A[]=new long[N]; long B[]=new long[N]; int z=0; long sum=0,y=0; while(z<N){ A[z]=stdIn.nextInt(); B[z]=stdIn.nextInt(); z++; }z--; while(z>=0) { A[z]+=sum; while(true) { if(A[z]%B[z]==0) break; y=A[z]/B[z]+1; sum+=y*B[z]-A[z]; A[z]=y*B[z]; } z--; } System.out.println(sum); } }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | zaki1236 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 525 Byte |
Status | AC |
Exec Time | 599 ms |
Memory | 87016 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 | 575 ms | 66680 KB |
02.txt | AC | 590 ms | 65548 KB |
03.txt | AC | 588 ms | 62784 KB |
04.txt | AC | 587 ms | 85340 KB |
05.txt | AC | 587 ms | 65372 KB |
06.txt | AC | 569 ms | 62268 KB |
07.txt | AC | 526 ms | 63484 KB |
08.txt | AC | 590 ms | 87016 KB |
09.txt | AC | 533 ms | 65268 KB |
10.txt | AC | 595 ms | 67528 KB |
11.txt | AC | 526 ms | 64192 KB |
12.txt | AC | 491 ms | 61216 KB |
13.txt | AC | 505 ms | 62876 KB |
14.txt | AC | 599 ms | 63148 KB |
15.txt | AC | 92 ms | 19796 KB |
16.txt | AC | 93 ms | 18644 KB |
s1.txt | AC | 94 ms | 18516 KB |
s2.txt | AC | 94 ms | 18772 KB |