結果
| 問題 |
No.1029 JJOOII 3
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-04-17 21:43:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 482 bytes |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 82,300 KB |
| 実行使用メモリ | 92,672 KB |
| 最終ジャッジ日時 | 2024-10-03 11:53:28 |
| 合計ジャッジ時間 | 5,238 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / 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(len(T)):
NEXT=T[i:i+80]
for j in range(N):
ind=0
M=int(S[j][1])
for s in S[j][0]:
if ind<len(NEXT) and s==NEXT[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