結果

問題 No.561 東京と京都
ユーザー Mcpu3Mcpu3
提出日時 2018-12-14 17:44:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 453 bytes
コンパイル時間 551 ms
コンパイル使用メモリ 68,888 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 10:09:46
合計ジャッジ時間 1,605 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
	int D, T, K, tmp = 0;
	size_t N;
	cin >> N >> D;
	vector<int> dp(N + 1);
	dp[0] = 0;
	for (size_t i = 0; i < N; ++i) {
		dp[i + 1] = dp[i];
		cin >> T >> K;
		if (tmp % 2) {
			if (T - D > K) {
				dp[i + 1] += T - D;
				++tmp;
			}
			else dp[i + 1] += K;
		}
		else {
			if (T > K - D) dp[i + 1] += T;
			else {
				dp[i + 1] += K - D;
				++tmp;
			}
		}
	}
	cout << dp[N];
}
0