結果
問題 | No.561 東京と京都 |
ユーザー |
|
提出日時 | 2018-12-31 00:00:42 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 747 bytes |
コンパイル時間 | 943 ms |
コンパイル使用メモリ | 64,324 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-09 10:50:18 |
合計ジャッジ時間 | 1,649 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 4 |
other | WA * 17 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <algorithm> #include <iterator> #include <cmath> /* #include <map> #include <functional> #include <set> #include <queue> #include <cstdio> */ using namespace std; typedef long long ll; //typedef pair<ll, ll> P; #define rep(i, m) for(ll i=0;i<m;i++) int N, D; int T[110][2]; ll dp[110][2]; ll ep[110][110]; // rec(i, j) = max(rec(i, )) int main() { cin >> N >> D; rep(i, N) { cin >> T[i][0] >> T[i][1]; } dp[0][0] = 0; dp[0][1] = -D; rep(i,N) { rep(j, 2) { dp[i+1][j] = max(dp[i+1][j], dp[i][j] + T[i][j]); dp[i+1][(1-j)] = max(dp[i+1][1-j], dp[i][j] + T[i][1-j]-D); } } cout << max({dp[N-1][0], ep[N-1][0] }) << endl; }