結果

問題 No.561 東京と京都
ユーザー CleyLCleyL
提出日時 2020-02-11 23:15:36
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 419 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 64,024 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 17:21:52
合計ジャッジ時間 1,417 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 2 ms
6,676 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 2 ms
6,676 KB
testcase_18 WA -
testcase_19 AC 2 ms
6,676 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
long long dp[100][2];
int main(){
    int N,D;cin>>N>>D;
    for(int i = 0; N > i; i++){
        int a,b;cin>>a>>b;
        if(!i){
            dp[i][0] = a;
            dp[i][1] = b;
        }else{
            dp[i][0] = max(dp[i-1][0]+a,dp[i-1][1]+b-D);
            dp[i][1] = max(dp[i-1][1]+b,dp[i-1][0]+a-D);
        }
    }
    cout << max(dp[N-1][0],dp[N-1][1]) << endl;
}
0