結果

問題 No.561 東京と京都
ユーザー ミドリムシミドリムシ
提出日時 2017-10-23 10:17:41
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 842 bytes
コンパイル時間 516 ms
コンパイル使用メモリ 62,956 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 11:37:54
合計ジャッジ時間 1,156 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int N, D;
vector<int> T;
vector<int> K;
int dp[2][100];

int move(int now, int day){
    if(dp[now][day] != -1e9){
        return dp[now][day];
    }else if(day == N){
        return dp[now][day] = 0;
    }else if(now == 0){
        return dp[now][day] = max(T[day] + move(0, day + 1), K[day] + move(1, day + 1) - D);
    }else{
        return dp[now][day] = max(K[day] + move(1, day + 1), T[day] + move(0, day + 1) - D);
    }
}

int main(){
    cin >> N >> D;
    for(int i = 0; i < N; i++){
        int tokyo, kyoto;
        cin >> tokyo >> kyoto;
        T.push_back(tokyo);
        K.push_back(kyoto);
    }
    for(int i = 0; i < 2; i++){
        for(int j = 0; j < 100; j++){
            dp[i][j] = -1e9;
        }
    }
    cout << move(0, 0) << endl;
}
0