結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
15,388 KB
testcase_01 AC 106 ms
26,764 KB
testcase_02 AC 195 ms
45,256 KB
testcase_03 AC 242 ms
53,704 KB
testcase_04 AC 116 ms
28,860 KB
testcase_05 AC 6 ms
4,548 KB
testcase_06 AC 80 ms
21,596 KB
testcase_07 AC 192 ms
44,892 KB
testcase_08 AC 25 ms
9,088 KB
testcase_09 AC 236 ms
52,100 KB
testcase_10 AC 56 ms
16,148 KB
testcase_11 AC 18 ms
7,568 KB
testcase_12 AC 212 ms
48,184 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 3 ms
4,376 KB
testcase_15 AC 66 ms
18,608 KB
testcase_16 AC 31 ms
10,460 KB
testcase_17 AC 53 ms
15,140 KB
testcase_18 AC 32 ms
10,764 KB
testcase_19 AC 160 ms
38,280 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 69 ms
18,596 KB
testcase_27 AC 154 ms
36,824 KB
testcase_28 AC 77 ms
20,728 KB
testcase_29 AC 131 ms
32,432 KB
testcase_30 AC 143 ms
34,076 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 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