結果

問題 No.1029 JJOOII 3
ユーザー DenteDente
提出日時 2020-04-17 22:55:19
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 943 bytes
コンパイル時間 1,918 ms
コンパイル使用メモリ 165,512 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-14 15:15:48
合計ジャッジ時間 28,319 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,756 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 78 ms
6,944 KB
testcase_04 AC 257 ms
6,940 KB
testcase_05 AC 1,837 ms
6,940 KB
testcase_06 AC 1,340 ms
6,940 KB
testcase_07 AC 1,470 ms
6,944 KB
testcase_08 AC 1,956 ms
6,940 KB
testcase_09 AC 1,403 ms
6,940 KB
testcase_10 AC 1,574 ms
6,940 KB
testcase_11 TLE -
testcase_12 AC 996 ms
6,944 KB
testcase_13 AC 1,726 ms
6,940 KB
testcase_14 AC 1,915 ms
6,944 KB
testcase_15 AC 979 ms
6,944 KB
testcase_16 AC 1,246 ms
6,940 KB
testcase_17 AC 1,355 ms
6,940 KB
testcase_18 AC 1,368 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 3 ms
6,944 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 4 ms
6,944 KB
testcase_27 AC 4 ms
6,940 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 AC 3 ms
6,944 KB
testcase_30 AC 4 ms
6,940 KB
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

ll dp[300000 + 1];

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n, k;
    cin >> n >> k;
    string s[n];
    ll c[n];
    rep(i, n) {
        cin >> s[i] >> c[i];
    }
    string t = string(k, 'J') + string(k, 'O') + string(k, 'I');
    fill(dp, dp + 3 * k + 1, LINF);
    dp[0] = 0;
    rep(i, 3 * k) {
        rep(j, n) {
            int now = 0;
            rep(l, s[j].size()) {
                if (s[j][l] == t[i + now]) {
                    now++;
                    dp[i + now] = min(dp[i + now], dp[i] + c[j]);
                }
            }
        }
    }
    cout << (dp[3 * k] != LINF ? dp[3 * k] : -1) << endl;
    return 0;
}
0