結果

問題 No.561 東京と京都
ユーザー NoNo
提出日時 2017-08-26 02:13:48
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 2,357 ms
コンパイル使用メモリ 103,868 KB
実行使用メモリ 22,748 KB
最終ジャッジ日時 2023-08-05 19:56:58
合計ジャッジ時間 4,252 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
20,632 KB
testcase_01 AC 57 ms
20,664 KB
testcase_02 AC 57 ms
18,736 KB
testcase_03 AC 57 ms
20,680 KB
testcase_04 AC 56 ms
20,668 KB
testcase_05 AC 58 ms
22,716 KB
testcase_06 AC 57 ms
20,628 KB
testcase_07 AC 58 ms
22,748 KB
testcase_08 AC 57 ms
20,888 KB
testcase_09 AC 56 ms
20,748 KB
testcase_10 AC 58 ms
18,636 KB
testcase_11 AC 58 ms
20,608 KB
testcase_12 AC 59 ms
22,736 KB
testcase_13 AC 59 ms
20,592 KB
testcase_14 AC 58 ms
22,720 KB
testcase_15 AC 58 ms
22,596 KB
testcase_16 AC 59 ms
22,608 KB
testcase_17 AC 57 ms
20,704 KB
testcase_18 AC 58 ms
20,876 KB
testcase_19 AC 59 ms
20,776 KB
testcase_20 AC 58 ms
20,616 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace y
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int d = int.Parse(ss[1]);

            int mt = 0;
            int mk = 0 - d;
            for (int i = 0; i < n; i++)
            {
                ss = Console.ReadLine().Split();
                int t = int.Parse(ss[0]);
                int k = int.Parse(ss[1]);

                int w = mt;
                mt = mt + t;
                if (mt < mk - d + t) mt = mk - d + t;

                mk = mk + k;
                if (mk < w - d + k) mk = w - d + k;
            }
            int ans = Math.Max(mt, mk);
            Console.WriteLine(ans);
        }
    }
}
0