結果
問題 |
No.561 東京と京都
|
ユーザー |
|
提出日時 | 2018-06-22 15:59:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 532 bytes |
コンパイル時間 | 1,278 ms |
コンパイル使用メモリ | 158,064 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 17:58:44 |
合計ジャッジ時間 | 2,037 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long int ll; int n, d; int t[110], k[110]; int main() { cin.tie(0); ios::sync_with_stdio(false); cin >> n >> d; for (int i = 0; i < n; i++) { cin >> t[i] >> k[i]; } int a, b; a = t[0]; b = k[0] - d; for (int i = 1; i < n; i++) { int c = t[i] + max(a, b - d); int e = k[i] + max(b, a - d); a = c; b = e; } cout << max(a, b) << endl; return 0; }