結果

問題 No.45 回転寿司
ユーザー tntan
提出日時 2016-07-06 03:26:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 424 bytes
コンパイル時間 1,264 ms
コンパイル使用メモリ 159,688 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 14:55:03
合計ジャッジ時間 2,268 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second

int main()
{
	int n,t[1005],dp[1005];
	cin>>n;
	for(int i=0;i<n;i++)cin>>t[i];
	dp[0]=t[0];
	if(n>1)dp[1]=max(t[0],t[1]);
	if(n>2)
	{
		for(int i=2;i<n;i++)dp[i]=max(dp[i-2]+t[i],dp[i-1]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}
0