結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
nxteru
|
| 提出日時 | 2018-06-01 23:11:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 448 bytes |
| コンパイル時間 | 502 ms |
| コンパイル使用メモリ | 65,936 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-30 08:58:42 |
| 合計ジャッジ時間 | 1,291 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
typedef long long ll;
ll dp[2][2];
ll n,d;
int main(void){
scanf("%lld%lld",&n,&d);
dp[0][1]=-20000000;
for(int i=0;i<n;i++){
int u=(i+1)%2;
ll a,b;
scanf("%lld%lld",&a,&b);
dp[u][0]=max(dp[i%2][0]+a,dp[i%2][1]+a-d);
dp[u][1]=max(dp[i%2][0]+b-d,dp[i%2][1]+b);
}
printf("%lld\n",max(dp[n%2][0],dp[n%2][1]));
}
nxteru