結果

問題 No.561 東京と京都
ユーザー takubokudori
提出日時 2017-08-25 22:46:06
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 480 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 71,692 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-15 16:32:41
合計ジャッジ時間 1,274 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstdio>
using namespace std;

int main(void){
	int a[102][2];
	int n,m,s,t;
	cin>>n>>m;
	a[0][0]=a[0][1]=0;
	a[0][1]=-m;
	for(int i=1;i<=n;i++){
		cin>>s>>t;
		a[i][0]=max(a[i-1][0]+s,a[i-1][1]+s-m);
		a[i][1]=max(a[i-1][1]+t,a[i-1][0]+t-m);
	}
	cout<<max(a[n][0],a[n][1])<<endl;
	return 0;
}
0