Submission #2412424


Source Code Expand

using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var a = new long[n];
        var b = new long[n];
        for (int i = n - 1; i >= 0; i--)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            a[i] = long.Parse(line[0]);
            b[i] = long.Parse(line[1]);
        }
        Console.WriteLine(getAns(a, b));

    }
    public static long getAns(long[] a, long[] b)
    {
        var n = a.Length;
        var ret = getB(a[0], b[0]);
        for (int i = 1; i < n; i++)
        {
            var w = getB(a[i] + ret, b[i]);
            ret += w;
        }
        return ret;
    }
    public static long getB(long a, long b)
    {
        if (b >= a) return b - a;
        //else return ((a + b - 1) / b) * b - a;
        else
        {
            if (a % b == 0) return 0;
            else return (a / b + 1) * b - a;
        }
    }
}

Submission Info

Submission Time
Task A - Multiple Array
User bluemegane
Language C# (Mono 4.6.2.0)
Score 0
Code Size 1000 Byte
Status WA
Exec Time 135 ms
Memory 16588 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 2
AC × 14
WA × 4
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 130 ms 14552 KB
02.txt AC 129 ms 16584 KB
03.txt AC 129 ms 16580 KB
04.txt AC 133 ms 14528 KB
05.txt AC 129 ms 14548 KB
06.txt AC 135 ms 16584 KB
07.txt AC 110 ms 14552 KB
08.txt AC 132 ms 16584 KB
09.txt WA 110 ms 16584 KB
10.txt AC 129 ms 14532 KB
11.txt AC 107 ms 14536 KB
12.txt WA 90 ms 16588 KB
13.txt AC 109 ms 16588 KB
14.txt AC 133 ms 14536 KB
15.txt WA 20 ms 11092 KB
16.txt WA 20 ms 11220 KB
s1.txt AC 20 ms 9044 KB
s2.txt AC 20 ms 11092 KB