結果
問題 | No.561 東京と京都 |
ユーザー | pekempey |
提出日時 | 2017-08-25 22:27:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 404 bytes |
コンパイル時間 | 597 ms |
コンパイル使用メモリ | 72,704 KB |
最終ジャッジ日時 | 2025-01-05 02:28:33 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <string> using namespace std; int main() { int n, d; cin >> n >> d; int dpL = 0; int dpR = -1.01e9; for (int i = 0; i < n; i++) { int l, r; cin >> l >> r; int tmpL = dpL; int tmpR = dpR; dpL = max(tmpL + l, tmpR + l - d); dpR = max(tmpL - d + r, tmpR + r); } cout << max(dpL, dpR) << endl; }