結果

問題 No.561 東京と京都
ユーザー mbanmban
提出日時 2017-08-26 12:24:30
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 768 bytes
コンパイル時間 826 ms
コンパイル使用メモリ 111,092 KB
実行使用メモリ 26,136 KB
最終ジャッジ日時 2024-04-23 17:07:25
合計ジャッジ時間 1,803 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 21 ms
25,944 KB
testcase_01 AC 21 ms
24,028 KB
testcase_02 AC 22 ms
21,936 KB
testcase_03 AC 21 ms
23,776 KB
testcase_04 AC 25 ms
23,968 KB
testcase_05 AC 22 ms
24,028 KB
testcase_06 AC 22 ms
23,772 KB
testcase_07 AC 22 ms
24,096 KB
testcase_08 AC 22 ms
25,864 KB
testcase_09 AC 23 ms
23,968 KB
testcase_10 AC 23 ms
23,908 KB
testcase_11 AC 25 ms
26,136 KB
testcase_12 AC 22 ms
23,980 KB
testcase_13 AC 22 ms
23,856 KB
testcase_14 AC 22 ms
23,824 KB
testcase_15 AC 21 ms
21,936 KB
testcase_16 AC 22 ms
24,108 KB
testcase_17 AC 23 ms
26,136 KB
testcase_18 AC 21 ms
23,776 KB
testcase_19 AC 23 ms
25,996 KB
testcase_20 AC 23 ms
25,948 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

static class Program{
    static void Main(){
        new Magatro().Solve();
    }
}

class Magatro{
    public void Solve(){
        int n,d;
        int[]t,k;;
        string[]line = Console.ReadLine().Split(' ');
        n = int.Parse(line[0]);
        d = int.Parse(line[1]);
        t = new int[n];
        k = new int[n];
        for(int i =0;i<n;i++){
            line = Console.ReadLine().Split(' ');
            t[i]= int.Parse(line[0]);
            k[i]=int.Parse(line[1]);
        }
        int tt = t[0],kk = k[0]-d;
        for(int i =1;i<n;i++){
            int nt = Math.Max(tt,kk-d)+t[i];
            int nk = Math.Max(kk,tt-d)+k[i];
            tt = nt;
            kk = nk;
        }
        Console.WriteLine(Math.Max(tt,kk));
    }
}
0