結果
問題 |
No.561 東京と京都
|
ユーザー |
![]() |
提出日時 | 2018-10-12 17:31:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 382 bytes |
コンパイル時間 | 378 ms |
コンパイル使用メモリ | 58,180 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-12 17:50:50 |
合計ジャッジ時間 | 1,005 ms |
ジャッジサーバーID (参考情報) |
judge / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
#include <iostream> #include <algorithm> using namespace std; int t[105],k[105]; int main(void){ int n,d;cin>>n>>d; for(int i=0;i<n;i++){ cin>>t[i]>>k[i]; } int at=t[0],ak=k[0]-d; for(int i=1;i<n;i++){ int aT=at,aK=ak; at=max(aT+t[i],aK+t[i]-d); ak=max(ak+k[i],aT+k[i]-d); } cout<<max(at,ak)<<endl; return 0; }