結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
chocobo
|
| 提出日時 | 2018-09-14 16:57:14 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 851 bytes |
| コンパイル時間 | 1,731 ms |
| コンパイル使用メモリ | 95,124 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 18:51:20 |
| 合計ジャッジ時間 | 2,246 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
#define REP(i, n) for(ll i = 0; i < n; i++)
int main() {
ll n, d;
cin >> n >> d;
ll dp[2] = {0, -d};
REP(i, n){
ll t, k;
cin >> t >> k;
ll tmp[2];
tmp[0] = max(dp[0] + t, dp[1] + k - d);
tmp[1] = max(dp[1] + k, dp[0] + t - d);
dp[0] = tmp[0];
dp[1] = tmp[1];
}
cout << max(dp[0], dp[1]) << endl;
}
chocobo