Submission #3995938


Source Code Expand

using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC_Challenge
{
    class _009_A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            var aArray = new long[n];
            var bArray = new long[n];
            for(int i = 0; i < n; i++)
            {
                int[] ab = ReadInts();
                aArray[i] = ab[0];
                bArray[i] = ab[1];
            }
            Array.Reverse(aArray);
            Array.Reverse(bArray);
            long cnt = 0;
            for(int i = 0; i < n; i++)
            {
                long aNow = aArray[i] + cnt;
                if (aNow % bArray[i] == 0) continue;

                long dest = (aNow / bArray[i] + 1) * bArray[i];
                cnt += dest - aNow;
            }
            Console.WriteLine(cnt);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}

Submission Info

Submission Time
Task A - Multiple Array
User MiuraMiuMiu
Language C# (Mono 4.6.2.0)
Score 300
Code Size 1624 Byte
Status AC
Exec Time 141 ms
Memory 17292 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 18
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 137 ms 16596 KB
02.txt AC 138 ms 14560 KB
03.txt AC 136 ms 14548 KB
04.txt AC 137 ms 14552 KB
05.txt AC 138 ms 14548 KB
06.txt AC 137 ms 14548 KB
07.txt AC 115 ms 16600 KB
08.txt AC 141 ms 14560 KB
09.txt AC 115 ms 17292 KB
10.txt AC 138 ms 16600 KB
11.txt AC 113 ms 17292 KB
12.txt AC 92 ms 14548 KB
13.txt AC 115 ms 16596 KB
14.txt AC 140 ms 16600 KB
15.txt AC 22 ms 11092 KB
16.txt AC 22 ms 9172 KB
s1.txt AC 22 ms 9044 KB
s2.txt AC 22 ms 11220 KB