結果

問題 No.1029 JJOOII 3
ユーザー pekempeypekempey
提出日時 2020-04-17 22:33:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 865 bytes
コンパイル時間 1,655 ms
コンパイル使用メモリ 168,044 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 14:51:57
合計ジャッジ時間 5,699 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 114 ms
6,940 KB
testcase_04 AC 375 ms
6,940 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 9 ms
6,940 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 65 ms
6,944 KB
testcase_18 WA -
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 3 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,944 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 2 ms
6,944 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 3 ms
6,944 KB
testcase_30 AC 3 ms
6,944 KB
testcase_31 AC 3 ms
6,944 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 2 ms
6,944 KB
testcase_39 AC 2 ms
6,944 KB
testcase_40 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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, INT_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] != INT_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] == INT_MAX) {
    cout << -1 << endl;
  } else {
    cout << dp[3 * K] << endl;
  }
}
0