結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-27 07:27:30 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 820 bytes |
| コンパイル時間 | 769 ms |
| コンパイル使用メモリ | 74,064 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 23:07:12 |
| 合計ジャッジ時間 | 1,944 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void)
{
int N;
ll D;
vector<pair<ll, ll> > vv;
vector<pair<ll, ll> > dp;
cin >> N >> D;
for(int i=0; i < N; i++)
{
ll t, k;
cin >> t >> k;
vv.push_back(make_pair(t, k));
}
dp.push_back(make_pair(vv[0].first, vv[0].second - D));
for(int i=1; i < N; i++)
{
dp.push_back(make_pair(max(dp.back().first + vv[i].first,
dp.back().second + vv[i].first - D),
max(dp.back().first + vv[i].second - D,
dp.back().second + vv[i].second)));
}
cout << max(dp.back().first, dp.back().second) << endl;
return 0;
}