結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-11-03 02:52:43 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,241 bytes |
| コンパイル時間 | 647 ms |
| コンパイル使用メモリ | 87,812 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-22 14:27:29 |
| 合計ジャッジ時間 | 1,529 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
コンパイルメッセージ
main.cpp: In function ‘int dfs(int, int)’:
main.cpp:51:12: warning: control reaches end of non-void function [-Wreturn-type]
51 | dfs(day+1,place);
| ~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
using namespace std;
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define INF 1<<25
typedef long long ll;
int dy[8]={1,1,1,0,0,-1,-1,-1};
int dx[8]={-1,0,1,-1,1,-1,0,1};
struct S{
int a,b,c;
};
bool asc(const S& left,const S& right){
return left.c > right.c;
}
int N,D;
int y[101][2];
int dp[101][2];
int dfs(int day,int place){//day以降,placeの最大値
if(dp[day][place]!=0)return dp[day][place];
if(day>=N)return 0;
//move
dfs(day+1,1-place);
dfs(day+1,place);
}
int main(){
cin>>N>>D;
rep(i,N)cin>>y[i][0]>>y[i][1];
dp[0][1]=-D;
rep(i,N)rep(j,2){
//stay
dp[i+1][j]=max(dp[i+1][j],dp[i][j]+y[i][j]);
//move
dp[i+1][!j]=max(dp[i+1][!j],dp[i][j]+y[i][!j]-D);
}
cout<<max(dp[N][0],dp[N][1])<<endl;
return 0;
}