結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
|
| 提出日時 | 2014-10-19 16:03:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 566 bytes |
| コンパイル時間 | 506 ms |
| コンパイル使用メモリ | 61,184 KB |
| 実行使用メモリ | 16,840 KB |
| 最終ジャッジ日時 | 2024-11-24 07:13:38 |
| 合計ジャッジ時間 | 175,712 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 2 TLE * 28 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
#define MAX_N 1000
int v[MAX_N];
int dp[MAX_N];
int limit;
int sushi(int n, bool last){
int val;
if(limit <= n) return 0;
else if(last == true) val = sushi(n+1, false);
else val = std::max(sushi(n+1,false), sushi(n+1,true) + v[n]);
return (dp[n] = val);
}
int main(){
memset(dp,-1,sizeof(dp));
std::cin >> limit;
for(register int i = 0; i < limit; i++){
std::cin >> v[i];
}
printf("%d\n",sushi(0,false));
}