結果
| 問題 | No.45 回転寿司 |
| ユーザー |
|
| 提出日時 | 2018-12-31 12:34:42 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 678 bytes |
| コンパイル時間 | 1,680 ms |
| コンパイル使用メモリ | 62,392 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 19:51:52 |
| 合計ジャッジ時間 | 1,749 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <tuple>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i,b) for(ll i=0;i<(b);++i)
#define rep1(i,b) for(ll i=1;i<=(b);++i)
#define vec vector
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;
int N;
ll dp[1100];
ll V[1100];
ll rec(int i) {
if (i > N) {
return 0;
}
if (dp[i] < 0) {
dp[i] = max(rec(i+2)+V[i], rec(i+1));
}
return dp[i];
}
int main() {
cin >> N;
rep(i, N) {
cin >> V[i];
}
rep(i, 1100) {
dp[i] = -1;
}
cout << rec(0) << endl;
}