結果

問題 No.561 東京と京都
ユーザー zuvizudarzuvizudar
提出日時 2017-11-03 02:52:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,241 bytes
コンパイル時間 1,092 ms
コンパイル使用メモリ 88,676 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 04:03:44
合計ジャッジ時間 1,513 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |         ~~~^~~~~~~~~~~~~

ソースコード

diff #

#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;
}

0