Submission #4016396
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; public class Hello { private const int INF = 1000000007; public static void Main() { int N = Input.Cin<int>(); long[] A = new long[N]; long[] B = new long[N]; for (int i = N - 1; i != -1; i--) { A[i] = Input.Cin<long>(); B[i] = Input.Cin<long>(); } long ans = 0; for (int i = 0; i < N; i++) { long nowA = A[i] + ans; if (nowA % B[i] == 0) continue; long c = (long)Math.Floor(nowA / (B[i] + .0)) + 1; ans += c * B[i] - nowA; } Console.WriteLine(ans); } } public class Input { private static Queue<string> queue = new Queue<string>(); public static T Cin<T>() { if (queue.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); if (typeof(T) == typeof(int)) return (T)(object)int.Parse(queue.Dequeue()); else if (typeof(T) == typeof(long)) return (T)(object)long.Parse(queue.Dequeue()); else if (typeof(T) == typeof(string)) return (T)(object)(queue.Dequeue()); else if (typeof(T) == typeof(double)) return (T)(object)double.Parse(queue.Dequeue()); else return (T)(object)(""); } public static T Line<T>() { foreach (var s in Console.ReadLine().Split(' ')) queue.Enqueue(s); int c = queue.Count(); if (typeof(T) == typeof(int[])) { int[] ret = new int[c]; for (int i = 0; i < c; i++) ret[i] = Cin<int>(); return (T)(object)ret; } else if (typeof(T) == typeof(long[])) { long[] ret = new long[c]; for (int i = 0; i < c; i++) ret[i] = Cin<long>(); return (T)(object)ret; } else if (typeof(T) == typeof(string[])) { string[] ret = new string[c]; for (int i = 0; i < c; i++) ret[i] = Cin<string>(); return (T)(object)ret; } else if (typeof(T) == typeof(double[])) { double[] ret = new double[c]; for (int i = 0; i < c; i++) ret[i] = Cin<double>(); return (T)(object)ret; } else return (T)(object)(0); } }
Submission Info
Submission Time | |
---|---|
Task | A - Multiple Array |
User | chika_haru |
Language | C# (Mono 4.6.2.0) |
Score | 300 |
Code Size | 2333 Byte |
Status | AC |
Exec Time | 147 ms |
Memory | 17416 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 | 147 ms | 16736 KB |
02.txt | AC | 140 ms | 14688 KB |
03.txt | AC | 139 ms | 14688 KB |
04.txt | AC | 140 ms | 16736 KB |
05.txt | AC | 140 ms | 16736 KB |
06.txt | AC | 142 ms | 14688 KB |
07.txt | AC | 120 ms | 14688 KB |
08.txt | AC | 142 ms | 16736 KB |
09.txt | AC | 121 ms | 16736 KB |
10.txt | AC | 142 ms | 14688 KB |
11.txt | AC | 128 ms | 17416 KB |
12.txt | AC | 101 ms | 14688 KB |
13.txt | AC | 120 ms | 14688 KB |
14.txt | AC | 146 ms | 14688 KB |
15.txt | AC | 24 ms | 9300 KB |
16.txt | AC | 24 ms | 11348 KB |
s1.txt | AC | 24 ms | 11348 KB |
s2.txt | AC | 23 ms | 9300 KB |