結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
15,296 KB
testcase_01 AC 76 ms
26,688 KB
testcase_02 AC 142 ms
44,996 KB
testcase_03 AC 175 ms
53,544 KB
testcase_04 AC 87 ms
28,656 KB
testcase_05 AC 5 ms
4,512 KB
testcase_06 AC 59 ms
21,740 KB
testcase_07 AC 135 ms
44,928 KB
testcase_08 AC 20 ms
9,028 KB
testcase_09 AC 174 ms
52,000 KB
testcase_10 AC 43 ms
16,308 KB
testcase_11 AC 14 ms
7,804 KB
testcase_12 AC 159 ms
48,188 KB
testcase_13 AC 4 ms
4,628 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 51 ms
18,488 KB
testcase_16 AC 25 ms
10,408 KB
testcase_17 AC 40 ms
15,144 KB
testcase_18 AC 25 ms
10,980 KB
testcase_19 AC 122 ms
38,388 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 52 ms
18,800 KB
testcase_27 AC 113 ms
36,668 KB
testcase_28 AC 58 ms
20,792 KB
testcase_29 AC 100 ms
32,336 KB
testcase_30 AC 118 ms
33,808 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 245 ms
66,608 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];

  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;
}
0