結果

問題 No.45 回転寿司
ユーザー suakiisuakii
提出日時 2018-06-07 13:17:55
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 556 bytes
コンパイル時間 1,797 ms
コンパイル使用メモリ 143,876 KB
実行使用メモリ 53,552 KB
最終ジャッジ日時 2023-09-12 23:00:21
合計ジャッジ時間 7,141 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
15,308 KB
testcase_01 AC 114 ms
26,692 KB
testcase_02 AC 209 ms
45,052 KB
testcase_03 AC 255 ms
53,552 KB
testcase_04 AC 125 ms
28,716 KB
testcase_05 AC 6 ms
4,556 KB
testcase_06 AC 88 ms
21,616 KB
testcase_07 AC 207 ms
44,728 KB
testcase_08 AC 26 ms
9,248 KB
testcase_09 AC 244 ms
51,952 KB
testcase_10 AC 60 ms
16,096 KB
testcase_11 AC 19 ms
7,688 KB
testcase_12 AC 224 ms
48,176 KB
testcase_13 AC 5 ms
4,384 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 71 ms
18,496 KB
testcase_16 AC 33 ms
10,416 KB
testcase_17 AC 56 ms
15,100 KB
testcase_18 AC 34 ms
10,796 KB
testcase_19 AC 172 ms
38,212 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 4 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 73 ms
18,588 KB
testcase_27 AC 167 ms
36,780 KB
testcase_28 AC 82 ms
20,600 KB
testcase_29 AC 143 ms
32,340 KB
testcase_30 AC 150 ms
33,800 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;

int n, ans;
int a[1001];
int dp[1001][100000];

int f(int pos, int sum) {
    
    if (dp[pos][sum])
        return dp[pos][sum];
    
    if (pos >= n)
        return sum;
    else
        return dp[pos][sum] = max(f(pos+1, sum), f(pos+2, sum+a[pos]));
        
    
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i];
    
    cout << f(0, 0) << endl;
  
    return 0;
}

0