結果

問題 No.258 回転寿司(2)
ユーザー 小指が強い人小指が強い人
提出日時 2016-01-21 23:07:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 790 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 61,784 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-03 11:35:38
合計ジャッジ時間 3,591 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 WA -
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 WA -
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 WA -
testcase_13 AC 1 ms
6,944 KB
testcase_14 WA -
testcase_15 AC 1 ms
6,944 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
6,940 KB
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 WA -
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,944 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 1 ms
6,940 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
6,940 KB
testcase_37 AC 1 ms
6,940 KB
testcase_38 WA -
testcase_39 AC 2 ms
6,940 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 2 ms
6,940 KB
testcase_43 AC 1 ms
6,940 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 AC 1 ms
6,944 KB
testcase_47 WA -
testcase_48 AC 2 ms
6,944 KB
testcase_49 AC 2 ms
6,944 KB
testcase_50 WA -
testcase_51 AC 2 ms
6,940 KB
testcase_52 WA -
testcase_53 AC 1 ms
6,944 KB
testcase_54 AC 2 ms
6,940 KB
testcase_55 WA -
testcase_56 AC 1 ms
6,940 KB
testcase_57 AC 2 ms
6,940 KB
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 AC 1 ms
6,944 KB
testcase_63 WA -
testcase_64 AC 2 ms
6,944 KB
testcase_65 WA -
testcase_66 AC 2 ms
6,940 KB
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 2 ms
6,940 KB
testcase_70 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;

int main(void)
{
    int n;
    int v[1000] = {0};
    int dp[1000] = {0};
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> v[i];
    dp[0] = v[0];
    dp[1] = max(v[0], v[1]);
    for(int i = 2; i < n; i++) {
        dp[i] = max(dp[i - 2] + v[i], dp[i - 1]);
    }
    cout << dp[n - 1] << endl;
    vector<int> res;
    int k = n - 1;
    while(k >= 2) {
        if(dp[k - 2] + v[k] == dp[k]) {
            res.push_back(k);
            k = k - 2;
        }
        else {
            k = k - 1;
        }
    }
    if(k == 0)
        cout << 1 << endl;
    else
        cout << ((v[0] > v[1]) ? 1 : 2);
    for(int i = res.size() - 1; i >= 0; i--)
        cout << " " << res[i] + 1;
    cout << endl;
    return 0;
}
0