結果

問題 No.1029 JJOOII 3
ユーザー finefine
提出日時 2020-04-17 22:18:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 975 bytes
コンパイル時間 1,839 ms
コンパイル使用メモリ 169,536 KB
実行使用メモリ 13,892 KB
最終ジャッジ日時 2024-04-14 14:34:03
合計ジャッジ時間 31,584 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 154 ms
6,944 KB
testcase_04 AC 511 ms
6,940 KB
testcase_05 TLE -
testcase_06 WA -
testcase_07 WA -
testcase_08 TLE -
testcase_09 AC 1,826 ms
6,940 KB
testcase_10 TLE -
testcase_11 TLE -
testcase_12 AC 1,309 ms
6,944 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 479 ms
6,940 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 1,428 ms
6,940 KB
testcase_18 TLE -
testcase_19 AC 2 ms
6,944 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
6,944 KB
testcase_24 WA -
testcase_25 AC 2 ms
6,940 KB
testcase_26 WA -
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 3 ms
6,940 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'char target_char(int, int)':
main.cpp:14:1: warning: control reaches end of non-void function [-Wreturn-type]
   14 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

constexpr ll INF = 1e17;

inline char target_char(int nexi, int K) {
    if (nexi < K) return 'J';
    if (nexi < 2 * K) return 'O';
    if (nexi < 3 * K) return 'I';
    else '#';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, K;
    cin >> n >> K;

    vector<string> s(n);
    vector<ll> c(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i] >> c[i];
    }

    vector<ll> dp(3 * K + 1, INF);
    dp[0] = 0;
    for (int i = 0; i < 3 * K; ++i) {
        if (dp[i] >= INF) continue;
        for (int j = 0; j < n; ++j) {
            int nexi = i;
            for (char ch : s[j]) {
                char tar = target_char(nexi, K);
                if (tar == ch) ++nexi;
            }
            if (nexi == i) continue;
            dp[nexi] = min(dp[nexi], dp[i] + c[j]);
        }
    }
    cout << (dp[3 * K] >= INF ? -1 : dp[3 * K]) << "\n";
    return 0;
}
0