結果
| 問題 |
No.1029 JJOOII 3
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-04-17 21:45:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 475 bytes |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 82,008 KB |
| 実行使用メモリ | 93,084 KB |
| 最終ジャッジ日時 | 2024-10-03 11:56:32 |
| 合計ジャッジ時間 | 5,515 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 1 TLE * 2 -- * 35 |
ソースコード
import sys
input = sys.stdin.readline
N,K=map(int,input().split())
S=[input().split() for i in range(N)]
DP=[1<<63]*(3*K+2+100)
DP[0]=0
T=["J"]*K+["O"]*K+["I"]*K
for i in range(3*K):
#NEXT=T[i:i+80]
for j in range(N):
ind=0
M=int(S[j][1])
for s in S[j][0]:
if i+ind<3*K and s==T[i+ind]:
ind+=1
DP[i+ind]=min(DP[i+ind],DP[i]+M)
if 1<<63==DP[K*3]:
print(-1)
else:
print(DP[K*3])
titia