結果
| 問題 |
No.1029 JJOOII 3
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2020-04-17 21:41:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 474 bytes |
| コンパイル時間 | 373 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 83,456 KB |
| 最終ジャッジ日時 | 2024-10-03 11:48:44 |
| 合計ジャッジ時間 | 6,151 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | RE * 2 TLE * 1 -- * 35 |
ソースコード
import sys
input = sys.stdin.readline
N,K=map(int,input().split())
S=[input().split() for i in range(N)]
DP=[1<<63]*(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