結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
めうめう🎒
|
| 提出日時 | 2016-07-05 23:30:55 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 669 bytes |
| コンパイル時間 | 1,672 ms |
| コンパイル使用メモリ | 72,500 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-27 14:54:54 |
| 合計ジャッジ時間 | 2,177 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)
int sushi[1010] = {};
int n;
int memo[1010];
int dp(int now){
if(now >= n) return 0;
if(memo[now] != INF) return memo[now];
int a,b;
a = dp(now + 1);
b = dp(now + 2) + sushi[now];
return memo[now] = max(a,b);
}
int main() {
for(int i = 0;i < 1010;i++){
memo[i] = INF;
}
cin >> n;
for(int i = 0;i < n;i++){
cin >> sushi[i];
}
cout << dp(0) << endl;
return 0;
}
めうめう🎒