結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
tetsuzuki1115
|
| 提出日時 | 2018-04-01 15:36:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 679 bytes |
| コンパイル時間 | 887 ms |
| コンパイル使用メモリ | 82,796 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-26 05:27:34 |
| 合計ジャッジ時間 | 1,550 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
long long MOD = 1000000007;
int main() {
int N;
long long D;
cin >> N >> D;
long long a[2] = {0};
a[1] = -D;
for ( int i = 0; i < N; i++ ) {
long long t,k;
cin >> t >> k;
long long x[2];
x[0] = a[0]; x[1] = a[1];
a[0] = max( x[0]+t, x[1]-D+t );
a[1] = max( x[1]+k, x[0]-D+k );
}
cout << max( a[0], a[1] ) << endl;
return 0;
}
tetsuzuki1115