結果

問題 No.1029 JJOOII 3
ユーザー queeequeee
提出日時 2020-04-17 22:22:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 756 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 77,252 KB
実行使用メモリ 13,148 KB
最終ジャッジ日時 2024-04-14 14:39:33
合計ジャッジ時間 28,977 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
12,896 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 86 ms
6,944 KB
testcase_04 AC 275 ms
6,944 KB
testcase_05 AC 1,944 ms
6,940 KB
testcase_06 AC 1,532 ms
6,944 KB
testcase_07 AC 1,565 ms
6,940 KB
testcase_08 TLE -
testcase_09 AC 1,568 ms
6,944 KB
testcase_10 AC 1,741 ms
6,944 KB
testcase_11 TLE -
testcase_12 AC 1,136 ms
6,940 KB
testcase_13 AC 1,916 ms
6,940 KB
testcase_14 TLE -
testcase_15 AC 1,047 ms
6,940 KB
testcase_16 AC 1,376 ms
6,940 KB
testcase_17 AC 1,532 ms
6,940 KB
testcase_18 AC 1,496 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,940 KB
testcase_22 AC 3 ms
6,944 KB
testcase_23 AC 3 ms
6,940 KB
testcase_24 AC 3 ms
6,944 KB
testcase_25 AC 3 ms
6,940 KB
testcase_26 AC 3 ms
6,944 KB
testcase_27 AC 4 ms
6,940 KB
testcase_28 AC 3 ms
6,944 KB
testcase_29 AC 3 ms
6,940 KB
testcase_30 AC 3 ms
6,944 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 <iostream>
#include <cmath>
#include <queue>
#include <cassert>
using namespace std; typedef long long ll; const ll INF=1e18;

int main() {
  int n,k; cin>>n>>k;
  string t;
  for(int i=0;i<k;i++) t+="J";
  for(int i=0;i<k;i++) t+="O";
  for(int i=0;i<k;i++) t+="I";

  string s[n]; ll c[n];
  for(int i=0;i<n;i++) {
    cin>>s[i]>>c[i];
  }

  ll v[3*k+1];
  for(int i=0;i<=3*k;i++) v[i]=INF; v[0]=0;
  for(int i=0;i<3*k;i++) {
    for(int j=0;j<n;j++) {
      int u=i;
      for(char ch:s[j]) {
        if (ch == t[u]) u++;
        if (u == 3*k) break;
      }
      v[u] = min(v[u], v[i]+c[j]);
    }
  }
  /*
  for(int i=0;i<=3*k;i++) {
    cout<<v[i]<<" ";
  } cout<<endl;*/
  if (v[3*k] == INF) cout<<"-1"<<endl;
  else cout<<v[3*k]<<endl;
}
0