Submission #1113784
Source Code Expand
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); long[] buttons = new long[n]; long[] mul = new long[n]; for(int i=0;i<n;i++){ buttons[i] = in.nextLong(); mul[i] = in.nextLong(); } long resevoir = 0; for(int i=mul.length-1;i>=0;i--){ long add = (buttons[i]+resevoir)%mul[i]==0?(buttons[i]+resevoir)%mul[i]:mul[i] - (buttons[i]+resevoir)%mul[i]; resevoir += add; } System.out.println(resevoir); } }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | tienanhnguyen |
Language | Java8 (OpenJDK 1.8.0) |
Score | 300 |
Code Size | 570 Byte |
Status | AC |
Exec Time | 594 ms |
Memory | 67612 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 | 576 ms | 64352 KB |
02.txt | AC | 572 ms | 64052 KB |
03.txt | AC | 569 ms | 62844 KB |
04.txt | AC | 559 ms | 65256 KB |
05.txt | AC | 576 ms | 64820 KB |
06.txt | AC | 572 ms | 61972 KB |
07.txt | AC | 523 ms | 62044 KB |
08.txt | AC | 586 ms | 64404 KB |
09.txt | AC | 485 ms | 64096 KB |
10.txt | AC | 588 ms | 63852 KB |
11.txt | AC | 549 ms | 65436 KB |
12.txt | AC | 508 ms | 63140 KB |
13.txt | AC | 531 ms | 63220 KB |
14.txt | AC | 594 ms | 67612 KB |
15.txt | AC | 92 ms | 20948 KB |
16.txt | AC | 92 ms | 21716 KB |
s1.txt | AC | 92 ms | 20820 KB |
s2.txt | AC | 92 ms | 19668 KB |