結果
問題 | No.1029 JJOOII 3 |
ユーザー | autumn-eel |
提出日時 | 2020-04-17 22:32:14 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 848 bytes |
コンパイル時間 | 1,603 ms |
コンパイル使用メモリ | 165,176 KB |
実行使用メモリ | 267,108 KB |
最終ジャッジ日時 | 2024-04-14 14:49:30 |
合計ジャッジ時間 | 7,897 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
10,704 KB |
testcase_01 | AC | 3 ms
6,940 KB |
testcase_02 | AC | 5 ms
15,828 KB |
testcase_03 | WA | - |
testcase_04 | AC | 50 ms
61,960 KB |
testcase_05 | WA | - |
testcase_06 | AC | 212 ms
132,132 KB |
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 | 176 ms
200,648 KB |
testcase_16 | AC | 165 ms
205,020 KB |
testcase_17 | AC | 238 ms
208,772 KB |
testcase_18 | WA | - |
testcase_19 | AC | 5 ms
14,804 KB |
testcase_20 | AC | 25 ms
113,492 KB |
testcase_21 | AC | 25 ms
109,908 KB |
testcase_22 | AC | 25 ms
108,756 KB |
testcase_23 | AC | 25 ms
110,804 KB |
testcase_24 | AC | 25 ms
109,652 KB |
testcase_25 | AC | 26 ms
113,492 KB |
testcase_26 | AC | 34 ms
151,764 KB |
testcase_27 | AC | 36 ms
163,280 KB |
testcase_28 | AC | 35 ms
160,340 KB |
testcase_29 | AC | 34 ms
157,908 KB |
testcase_30 | AC | 37 ms
165,208 KB |
testcase_31 | AC | 35 ms
158,032 KB |
testcase_32 | WA | - |
testcase_33 | AC | 270 ms
260,796 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 3 ms
6,944 KB |
testcase_38 | WA | - |
testcase_39 | AC | 4 ms
12,364 KB |
testcase_40 | AC | 4 ms
14,032 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i,n)for(int i=0;i<n;i++) using namespace std; typedef long long ll; typedef pair<int,int>P; const int MOD=1000000007; const int INF=0x3f3f3f3f; const ll INFL=0x3f3f3f3f3f3f3f3f; string s[100]; int c[100]; ll dp[320000]; int nx[100][3200000]; int main(){ int n,K;cin>>n>>K; rep(i,n){ cin>>s[i]>>c[i]; } rep(i,n){ rep(j,3*K){ if(j){ int l=j/K,r=(j+100)/K; if(l==r){ nx[i][j]=nx[i][j-1]+1; continue; } } int cur=j; rep(k,s[i].size()){ char want=(cur<K?'J':(cur<2*K?'O':'I')); if(cur<3*K&&s[i][k]==want)cur++; } cur=min(cur,3*K); nx[i][j]=cur; } } memset(dp,0x3f,sizeof(dp)); dp[0]=0; rep(i,3*K){ if(dp[i]==INFL)continue; rep(j,n){ dp[nx[j][i]]=min(dp[nx[j][i]],dp[i]+c[j]); } } if(dp[3*K]==INFL)puts("-1"); else cout<<dp[3*K]<<endl; }