結果

問題 No.1029 JJOOII 3
ユーザー 👑 hitonanodehitonanode
提出日時 2020-04-20 01:55:52
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 974 bytes
コンパイル時間 2,945 ms
コンパイル使用メモリ 200,008 KB
実行使用メモリ 12,576 KB
最終ジャッジ日時 2024-04-16 00:28:31
合計ジャッジ時間 18,484 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 45 ms
5,376 KB
testcase_04 AC 125 ms
5,376 KB
testcase_05 AC 1,083 ms
5,376 KB
testcase_06 AC 791 ms
5,376 KB
testcase_07 AC 661 ms
5,376 KB
testcase_08 AC 1,037 ms
5,376 KB
testcase_09 AC 819 ms
5,376 KB
testcase_10 AC 1,200 ms
5,376 KB
testcase_11 AC 1,269 ms
5,632 KB
testcase_12 AC 679 ms
5,376 KB
testcase_13 AC 1,008 ms
5,504 KB
testcase_14 AC 1,213 ms
5,632 KB
testcase_15 AC 295 ms
5,376 KB
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 1,048 ms
5,376 KB
testcase_18 AC 1,191 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 3 ms
5,376 KB
testcase_22 AC 3 ms
5,376 KB
testcase_23 AC 3 ms
5,376 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 2 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 3 ms
5,376 KB
testcase_31 AC 3 ms
5,376 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;
using lint = long long int;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define REP(i, n) FOR(i,0,n)

int main()
{
    int N, K;
    cin >> N >> K;
    vector<string> S(N);
    vector<lint> C(N);
    REP(i, N) cin >> S[i] >> C[i];

    vector<lint> cost(K * 3 + 1, 9e18);
    cost[0] = 0;
    REP(i, K * 3) if (cost[i] < cost[i + 1])
    {
        REP(j, N)
        {
            int now = i;
            for (auto c : S[j])
            {
                if (now < K and c == 'J') now++;
                if (now >= K and now < K * 2 and c == 'O') now++;
                if (now >= K * 2 and now < K * 3 and c == 'I') now++;
            }
            cost[now] = min(cost[now], cost[i] + C[j]);
        }
    }
    cout << (cost.back() == 9e18 ? -1 : cost.back()) << '\n';
}
0