結果

問題 No.561 東京と京都
ユーザー HAHAHAHAHAHA
提出日時 2017-09-11 03:58:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 342 bytes
コンパイル時間 1,414 ms
コンパイル使用メモリ 162,416 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 03:22:52
合計ジャッジ時間 2,221 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int dp[101][2];

int main(){
	int n,k,a,b;
	cin >> n >> k;
	
	cin >> a >> b;
	dp[0][0]=a;
	dp[0][1]=b-k;
	for(int i=1;i<n;i++){
		cin >> a >> b;
		dp[i][0]=max(dp[i-1][0]+a, dp[i-1][1]-k);
		dp[i][1]=max(dp[i-1][1]+b, dp[i-1][0]-k);
	}
	
	cout << max(dp[n-1][0], dp[n-1][1]) << endl;
	return 0;
}
0