結果

問題 No.1029 JJOOII 3
ユーザー DenteDente
提出日時 2020-04-17 22:50:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,009 bytes
コンパイル時間 1,570 ms
コンパイル使用メモリ 165,312 KB
実行使用メモリ 13,760 KB
最終ジャッジ日時 2024-04-14 15:05:30
合計ジャッジ時間 31,682 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,760 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 94 ms
6,944 KB
testcase_04 AC 304 ms
6,940 KB
testcase_05 TLE -
testcase_06 AC 1,635 ms
6,940 KB
testcase_07 AC 1,773 ms
6,940 KB
testcase_08 TLE -
testcase_09 AC 1,716 ms
6,944 KB
testcase_10 AC 1,868 ms
6,940 KB
testcase_11 TLE -
testcase_12 AC 1,199 ms
6,940 KB
testcase_13 TLE -
testcase_14 TLE -
testcase_15 AC 1,266 ms
6,940 KB
testcase_16 AC 1,339 ms
6,944 KB
testcase_17 AC 1,576 ms
6,944 KB
testcase_18 AC 1,608 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 3 ms
6,944 KB
testcase_21 AC 3 ms
6,940 KB
testcase_22 AC 3 ms
6,944 KB
testcase_23 AC 2 ms
6,944 KB
testcase_24 AC 3 ms
6,940 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 4 ms
6,944 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 AC 3 ms
6,944 KB
testcase_30 AC 3 ms
6,940 KB
testcase_31 AC 3 ms
6,944 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];
int k;

char t(int n) {
    if (n < k)
        return 'J';
    else if (n < 2 * k)
        return 'O';
    else
        return 'I';
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n >> k;
    string s[n];
    ll c[n];
    rep(i, n) {
        cin >> s[i] >> c[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