結果
| 問題 | No.45 回転寿司 |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-04 06:08:17 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 5,000 ms |
| + 352µs | |
| コード長 | 403 bytes |
| 記録 | |
| コンパイル時間 | 271 ms |
| コンパイル使用メモリ | 74,972 KB |
| 実行使用メモリ | 9,900 KB |
| 最終ジャッジ日時 | 2026-10-08 13:57:13 |
| 合計ジャッジ時間 | 2,833 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int memo[1010], v[1010], n;
int func(int p)
{
if (p>=n) return 0;
int& res=memo[p];
if (~res) return res;
return res=max({res, func(p+1), func(p+2)+v[p]});
}
int main()
{
while (cin>>n) {
for(int i=0;i<n;++i) {
cin>>v[i];
memo[i]=-1;
}
cout<<func(0)<<endl;
}
}
hogeover30