結果

問題 No.561 東京と京都
ユーザー sawfishsawfish
提出日時 2022-10-23 03:27:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 493 ms
コンパイル使用メモリ 65,504 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-14 17:33:19
合計ジャッジ時間 4,034 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>

using namespace std;
using LL = long long;
using ULL = unsigned long long;

LL dp[2][101];
int T[101], K[101];

int main() {
    int N, D;
    cin >> N >> D;

    for (int i = 1; i <= N; i++) cin >> T[i] >> K[i];

    dp[1][0] = T[1];
    dp[1][1] = K[1] - D;
    for (int i = 2; i <= N; i++) {
        dp[i][0] = max(T[i] + dp[i - 1][0], T[i] + dp[i - 1][1] - D);
        dp[i][1] = max(K[i] + dp[i - 1][1], K[i] + dp[i - 1][0] - D);
    }

    cout << max(dp[N][0], dp[N][1]) << endl;
}
0