結果
| 問題 | No.45 回転寿司 |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-04 06:08:17 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 403 bytes |
| 記録 | |
| コンパイル時間 | 655 ms |
| コンパイル使用メモリ | 56,544 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 11:07:11 |
| 合計ジャッジ時間 | 2,013 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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