Submission #4016374


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>();
        int[] A = new int[N];
        int[] B = new int[N];
        for (int i = N - 1; i != -1; i--) { A[i] = Input.Cin<int>(); B[i] = Input.Cin<int>(); }
        int ans = 0;
        for (int i = 0; i < N; i++)
        {
            if ((A[i] + ans) % B[i] == 0) continue;
            int c = (int)Math.Floor((A[i] + ans) / (B[i] + .0)) + 1;
            ans += c * B[i] - (A[i] + ans);
        }
        Console.WriteLine(ans);
    }
    public static long GCD(long a, long b)
    {
        if (a < b) GCD(b, a);
        long d = a % b;
        while (b != 0)
        {
            d = a % b;
            a = b;
            b = d;
        }
        return a;
    }
    public static long LCM(long a, long b)
    {
        return a / GCD(a, b) * b;
    }
}

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 0
Code Size 2647 Byte
Status WA
Exec Time 141 ms
Memory 15944 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 9
WA × 9
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 WA 139 ms 13884 KB
02.txt WA 139 ms 15932 KB
03.txt WA 137 ms 13884 KB
04.txt WA 141 ms 15932 KB
05.txt WA 139 ms 15932 KB
06.txt WA 139 ms 13900 KB
07.txt AC 118 ms 15940 KB
08.txt WA 140 ms 15932 KB
09.txt AC 117 ms 13892 KB
10.txt WA 138 ms 15932 KB
11.txt AC 116 ms 13892 KB
12.txt AC 101 ms 15944 KB
13.txt WA 118 ms 13896 KB
14.txt AC 138 ms 13880 KB
15.txt AC 24 ms 11220 KB
16.txt AC 23 ms 11220 KB
s1.txt AC 23 ms 9172 KB
s2.txt AC 23 ms 11220 KB