結果

問題 No.45 回転寿司
ユーザー DialBirdDialBird
提出日時 2017-02-09 10:06:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 285 ms / 5,000 ms
コード長 683 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 62,744 KB
実行使用メモリ 66,676 KB
最終ジャッジ日時 2023-08-27 15:20:15
合計ジャッジ時間 4,596 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
15,300 KB
testcase_01 AC 101 ms
26,740 KB
testcase_02 AC 187 ms
44,996 KB
testcase_03 AC 236 ms
53,696 KB
testcase_04 AC 110 ms
28,688 KB
testcase_05 AC 6 ms
4,536 KB
testcase_06 AC 77 ms
21,672 KB
testcase_07 AC 180 ms
45,004 KB
testcase_08 AC 26 ms
9,028 KB
testcase_09 AC 225 ms
52,004 KB
testcase_10 AC 57 ms
16,288 KB
testcase_11 AC 18 ms
7,572 KB
testcase_12 AC 206 ms
48,392 KB
testcase_13 AC 6 ms
4,400 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 62 ms
18,620 KB
testcase_16 AC 31 ms
10,536 KB
testcase_17 AC 50 ms
15,140 KB
testcase_18 AC 31 ms
10,856 KB
testcase_19 AC 148 ms
38,084 KB
testcase_20 AC 4 ms
4,380 KB
testcase_21 AC 5 ms
4,528 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 66 ms
18,584 KB
testcase_27 AC 141 ms
36,804 KB
testcase_28 AC 71 ms
20,588 KB
testcase_29 AC 123 ms
32,428 KB
testcase_30 AC 134 ms
33,776 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 285 ms
66,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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];

  dp[idx][total] = MAX(solve(idx + 1, total), solve(idx + 2, total + v_list[idx]));
  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;
}
0