結果
| 問題 | 
                            No.45 回転寿司
                             | 
                    
| ユーザー | 
                             sntea
                         | 
                    
| 提出日時 | 2015-08-26 21:52:24 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 3 ms / 5,000 ms | 
| コード長 | 820 bytes | 
| コンパイル時間 | 1,410 ms | 
| コンパイル使用メモリ | 80,332 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-27 12:15:34 | 
| 合計ジャッジ時間 | 2,662 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 30 | 
ソースコード
#include <iostream>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <utility>
#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
typedef pair<int,int> P;
typedef long long int LL;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin>>N;
	vector<int> V(N);
	vector<int> dp(N);
	REP(i,N)	cin>>V[i];
	dp[0]=V[0];
	FOR(i,1,N){
		dp[i]=0;
		FOR(j,2,4){
			if(i-j>=0){
				dp[i]=max(dp[i-j],dp[i]);
			}
		}
		dp[i]+=V[i];
	}
	//REP(i,N)	cout<<dp[i]<<' ';
	//cout<<endl;
	cout<<max(dp[N-1],dp[N-2])<<endl;
	return 0;
}
            
            
            
        
            
sntea