結果

問題 No.45 回転寿司
ユーザー 777yuuki12323
提出日時 2017-06-27 17:14:10
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 878 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 642 ms
コンパイル使用メモリ 94,420 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-02 04:32:41
合計ジャッジ時間 2,319 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>


typedef long long ll;
#define fi first
#define se second
const ll mod = 1000000007;
//              123456789

using namespace std;

///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int N;
int v[1123];
int cost[1123][2];

int main(){
	
	int i;
	int j;
	
	cin>>N;
	
	fill( cost[0], cost[N], 0 );
	
	for( i = 0; i < N; i++ ){
		scanf("%d", v+i);
	}
	
	cost[0][0] = 0;
	cost[0][1] = v[0];
	
	for( i = 1; i < N; i++ ){
		cost[i][0] = max( cost[i-1][0], cost[i-1][1] );
		cost[i][1] = cost[i-1][0] + v[i];
	}
	
	cout<<max(cost[N-1][0], cost[N-1][1]);

	
	return 0;
}
0