結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2014-10-18 22:38:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 5,000 ms |
| コード長 | 608 bytes |
| コンパイル時間 | 1,358 ms |
| コンパイル使用メモリ | 70,240 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 10:18:55 |
| 合計ジャッジ時間 | 2,775 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <fstream>
#include <sstream>
using namespace std;
typedef long long ll;
int N;
int V[1010];
bool done[1010];
int dp[1010];
int solve(int k){
if(k >= N)return 0;
if(done[k])return dp[k];
int res = max(solve(k + 1), V[k] + solve(k + 2));
done[k] = true;
return dp[k] = res;
}
int main(){
cin >> N;
for(int i=0;i<N;i++)cin >> V[i];
cout << solve(0) << endl;
return 0;
}