結果
| 問題 | 
                            No.45 回転寿司
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2017-02-09 10:05:25 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 282 ms / 5,000 ms | 
| コード長 | 725 bytes | 
| コンパイル時間 | 629 ms | 
| コンパイル使用メモリ | 62,280 KB | 
| 実行使用メモリ | 66,560 KB | 
| 最終ジャッジ日時 | 2024-12-27 15:50:47 | 
| 合計ジャッジ時間 | 4,269 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 30 | 
ソースコード
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
using namespace std;
#define REP(i,first,last) for (int i=first;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)
const int MAX_N = 1000;
const int MAX_V = 100;
int N;
vector<int> v_list;
int dp[MAX_N + 1][MAX_N * MAX_V + 1];
int solve(int idx, int total){
  if (idx >= N) return total;
  if (dp[idx][total]) return dp[idx][total];
  int res_1 = solve(idx + 1, total);
  int res_2 = solve(idx + 2, total + v_list[idx]);
  dp[idx][total] = MAX(res_1, res_2);
  return dp[idx][total];
}
int main(){
  cin >> N;
  int val;
  REP(i,0,N){
    cin >> val;
    v_list.push_back(val);
  }
  cout << solve(0, 0) << endl;
}