結果

問題 No.45 回転寿司
ユーザー yuki2006
提出日時 2014-10-19 16:26:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 585 bytes
コンパイル時間 469 ms
コンパイル使用メモリ 59,988 KB
実行使用メモリ 13,696 KB
最終ジャッジ日時 2024-11-24 07:20:07
合計ジャッジ時間 175,637 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 2 TLE * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#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));
 std::cout.flush();
}
0