結果

問題 No.561 東京と京都
ユーザー ミドリムシミドリムシ
提出日時 2017-10-23 10:14:23
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 601 bytes
コンパイル時間 702 ms
コンパイル使用メモリ 62,812 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-05-01 11:37:33
合計ジャッジ時間 4,230 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int N, D;
vector<int> T;
vector<int> K;

int move(int now, int day){
    if(day == N){
        return 0;
    }else if(now == 0){
        return max(T[day] + move(0, day + 1), K[day] + move(1, day + 1) - D);
    }else{
        return 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);
    }
    cout << move(0, 0) << endl;
}
0