結果

問題 No.1029 JJOOII 3
ユーザー pekempeypekempey
提出日時 2020-04-17 22:36:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 871 bytes
コンパイル時間 1,617 ms
コンパイル使用メモリ 168,580 KB
実行使用メモリ 12,576 KB
最終ジャッジ日時 2024-04-14 14:54:46
合計ジャッジ時間 25,647 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
12,324 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 119 ms
6,940 KB
testcase_04 AC 395 ms
6,940 KB
testcase_05 AC 1,754 ms
6,944 KB
testcase_06 AC 1,285 ms
6,940 KB
testcase_07 AC 1,511 ms
6,940 KB
testcase_08 AC 1,769 ms
6,940 KB
testcase_09 AC 1,413 ms
6,944 KB
testcase_10 AC 1,567 ms
6,940 KB
testcase_11 TLE -
testcase_12 AC 1,017 ms
6,944 KB
testcase_13 AC 1,842 ms
6,944 KB
testcase_14 AC 1,913 ms
6,940 KB
testcase_15 AC 335 ms
6,944 KB
testcase_16 AC 3 ms
6,944 KB
testcase_17 AC 1,030 ms
6,944 KB
testcase_18 AC 1,732 ms
6,944 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 3 ms
6,944 KB
testcase_22 AC 3 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 3 ms
6,940 KB
testcase_27 AC 3 ms
6,940 KB
testcase_28 AC 3 ms
6,940 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 3 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;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N, K; cin >> N >> K;
  vector<ll> dp(3 * K + 1, LLONG_MAX);
  dp[0] = 0;
  vector<string> S(N);
  vector<ll> C(N);
  rep(i, N) cin >> S[i] >> C[i];
  rep(i, 3 * K) if (dp[i] != LLONG_MAX) {
    rep(j, N) {
      int l = i;
      for (char c : S[j]) {
        if (l < K) {
          if (c == 'J') l++;
        } else if (l < 2 * K) {
          if (c == 'O') l++;
        } else if (l < 3 * K) {
          if (c == 'I') l++;
        }
      }
      dp[l] = min(dp[l], dp[i] + C[j]);
    }
  }
  if (dp[3 * K] == LLONG_MAX) {
    cout << -1 << endl;
  } else {
    cout << dp[3 * K] << endl;
  }
}
0