結果

問題 No.45 回転寿司
ユーザー IL_mstaIL_msta
提出日時 2015-06-22 20:26:35
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,546 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 82,076 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-03 09:34:39
合計ジャッジ時間 1,548 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,944 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 1 ms
6,940 KB
testcase_14 AC 1 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 1 ms
6,944 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 AC 1 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 1 ms
6,940 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 AC 1 ms
6,944 KB
testcase_32 WA -
testcase_33 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>

#include <algorithm>
#include <cmath>

#include <string>
#include <list>
#include <queue>
#include <vector>
#include <complex>

/////////
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) std::cout<<(p)<<std::endl;
/////////
typedef long long LL;
typedef long double LD;
/////////
using namespace::std;
/////////
int N;
int V[1000];
int solve(int next,int wa,int xx){
	if( next>= N){
		return wa;
	}
	////
	int ans=0;
	int tans=0;
	if(xx==0){
		ans = solve(next+1,wa,1);
	}
	else if(xx=2){
		ans = solve(next+1,wa+V[next],0);
	}
	else{//xx==1
		ans = solve(next+1,wa+V[next],0);
		tans = solve(next+1,wa,2);
		if(ans < tans){
			ans = tans;
		}
	}
	return ans;
}
const int dpMax = 1010;
int dp1[dpMax];
int dp2[dpMax];
int main(void){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::fixed;//
    //cout << setprecision(6);//
	
	cin>>N;
	rep(i,N)cin>>V[i];

	//int ans;
	//ans = solve(0,0,1);

	rep(i,dpMax)dp1[i]=0;
	dp1[0] = V[0];
	dp1[1] = V[1];//if(N==1){dp1[1] = 0}else{dp1[1]=V[1];}
	int temp;
	for(int k=0;k<N/2;++k)
	{
		for(int i=0;i<N;++i){
			if(dp1[i]>0){
				if(i+2<N){
					temp = dp1[i] + V[i+2];
					if(dp2[i+2]<temp){
						dp2[i+2] = temp;
					}
				}
				if(i+3<N){
					temp = dp1[i] + V[i+3];
					if( dp2[i+3] < temp){
						dp2[i+3] = temp;
					}
				}
			}
		}
		rep(i,dpMax){
			dp1[i] = dp2[i];
		}
	}
	if(dp1[N-1]<dp1[N-2]){
		P(dp1[N-2]);
	}else{
		P(dp1[N-1]);
	}
	return 0;
}
0