結果

問題 No.45 回転寿司
ユーザー suakiisuakii
提出日時 2018-06-07 13:52:02
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 272 ms / 5,000 ms
コード長 531 bytes
コンパイル時間 2,537 ms
コンパイル使用メモリ 143,644 KB
実行使用メモリ 66,652 KB
最終ジャッジ日時 2023-08-27 16:28:15
合計ジャッジ時間 5,071 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
15,368 KB
testcase_01 AC 94 ms
26,792 KB
testcase_02 AC 172 ms
45,148 KB
testcase_03 AC 211 ms
53,616 KB
testcase_04 AC 104 ms
28,712 KB
testcase_05 AC 5 ms
4,532 KB
testcase_06 AC 73 ms
21,668 KB
testcase_07 AC 170 ms
44,796 KB
testcase_08 AC 22 ms
9,120 KB
testcase_09 AC 208 ms
51,992 KB
testcase_10 AC 51 ms
16,172 KB
testcase_11 AC 17 ms
7,544 KB
testcase_12 AC 191 ms
48,148 KB
testcase_13 AC 5 ms
4,376 KB
testcase_14 AC 3 ms
4,380 KB
testcase_15 AC 62 ms
18,592 KB
testcase_16 AC 29 ms
10,504 KB
testcase_17 AC 49 ms
15,180 KB
testcase_18 AC 30 ms
10,908 KB
testcase_19 AC 142 ms
38,340 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 3 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 62 ms
18,724 KB
testcase_27 AC 139 ms
36,672 KB
testcase_28 AC 69 ms
20,888 KB
testcase_29 AC 117 ms
32,356 KB
testcase_30 AC 126 ms
33,940 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 272 ms
66,652 KB
権限があれば一括ダウンロードができます

ソースコード

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 (pos >= n)
        return sum;
    else if (dp[pos][sum])
        return dp[pos][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