結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
nenuon
|
| 提出日時 | 2018-03-02 23:55:12 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,000 bytes |
| コンパイル時間 | 871 ms |
| コンパイル使用メモリ | 94,196 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-22 23:14:39 |
| 合計ジャッジ時間 | 1,707 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// dp[i][j] := i日目にj(0->TOKYO)にいる時の最大値
int dp[111][2];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int N, D; cin >> N >> D;
int T[2][N];
FOR(i,0,111) FOR(j,0,2) dp[i][j] = -1e9;
dp[0][0] = 0;
FOR(i,0,N) cin >> T[0][i] >> T[1][i];
FOR(i,0,N) {
FOR(j,0,2) {
// 移動しない
dp[i+1][j] = max(dp[i+1][j], dp[i][j]+T[j][i]);
// 移動する
dp[i+1][j^1] = max(dp[i+1][j^1], dp[i][j]+T[j^1][i]-D);
}
}
cout << max(dp[N][0], dp[N][1]) << endl;
return 0;
}
nenuon