結果

問題 No.45 回転寿司
ユーザー suakiisuakii
提出日時 2018-06-07 13:49:34
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 529 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 143,456 KB
実行使用メモリ 53,500 KB
最終ジャッジ日時 2023-09-12 23:01:46
合計ジャッジ時間 6,784 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
15,256 KB
testcase_01 AC 105 ms
26,900 KB
testcase_02 AC 195 ms
45,128 KB
testcase_03 AC 239 ms
53,500 KB
testcase_04 AC 115 ms
28,648 KB
testcase_05 AC 5 ms
4,520 KB
testcase_06 AC 81 ms
21,504 KB
testcase_07 AC 192 ms
44,872 KB
testcase_08 AC 24 ms
9,036 KB
testcase_09 AC 236 ms
51,992 KB
testcase_10 AC 56 ms
16,168 KB
testcase_11 AC 18 ms
7,628 KB
testcase_12 AC 214 ms
48,112 KB
testcase_13 AC 4 ms
4,440 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 68 ms
18,396 KB
testcase_16 AC 31 ms
10,412 KB
testcase_17 AC 52 ms
15,068 KB
testcase_18 AC 32 ms
10,756 KB
testcase_19 AC 165 ms
38,064 KB
testcase_20 AC 3 ms
4,380 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 1 ms
4,376 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 1 ms
4,380 KB
testcase_26 AC 68 ms
18,568 KB
testcase_27 AC 154 ms
36,676 KB
testcase_28 AC 77 ms
20,592 KB
testcase_29 AC 133 ms
32,344 KB
testcase_30 AC 143 ms
33,744 KB
testcase_31 AC 2 ms
4,384 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][100001];
int f(int pos, int sum) {
    if (dp[pos][sum])
        return dp[pos][sum];
    else if (pos >= n)
        return sum;
    else
        return dp[pos][sum] = max(f(pos+2, sum+a[pos]),f(pos+1, sum));

}

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