Submission #5494646
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(); long A[] = new long[N]; long B[] = new long[N]; for(int i = 0; i < N; i++) { A[i] = sc.nextLong(); B[i] = sc.nextLong(); } long ans = 0; for(int i = N - 1; i >= 0; i--) { long 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 | 609 Byte |
Status | TLE |
Exec Time | 2109 ms |
Memory | 85700 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 | TLE | 2109 ms | 64548 KB |
02.txt | TLE | 2109 ms | 85700 KB |
03.txt | TLE | 2109 ms | 65544 KB |
04.txt | TLE | 2105 ms | 62548 KB |
05.txt | TLE | 2109 ms | 63260 KB |
06.txt | TLE | 2109 ms | 63100 KB |
07.txt | TLE | 2109 ms | 64904 KB |
08.txt | TLE | 2109 ms | 61020 KB |
09.txt | TLE | 2109 ms | 64072 KB |
10.txt | TLE | 2109 ms | 83828 KB |
11.txt | TLE | 2109 ms | 64224 KB |
12.txt | TLE | 2109 ms | 66336 KB |
13.txt | TLE | 2109 ms | 63476 KB |
14.txt | TLE | 2109 ms | 63948 KB |
15.txt | AC | 92 ms | 18900 KB |
16.txt | AC | 91 ms | 18772 KB |
s1.txt | AC | 91 ms | 19796 KB |
s2.txt | AC | 93 ms | 19412 KB |