結果
問題 | No.291 黒い文字列 |
ユーザー |
![]() |
提出日時 | 2020-04-10 13:32:16 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 992 bytes |
コンパイル時間 | 275 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 81,280 KB |
最終ジャッジ日時 | 2024-09-14 23:42:53 |
合計ジャッジ時間 | 12,965 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 12 WA * 3 TLE * 2 -- * 9 |
ソースコード
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools S = read().rstrip().decode() ques = S.count('?') def solve(a, b, c, d, e): stack = ['I'] * e + ['O'] * d + ['R'] * c + ['U'] * b + ['K'] * a K = 0 KU = 0 KUR = 0 KURO = 0 KUROI = 0 for x in S: if x == '?': x = stack.pop() if x == 'K': K += 1 elif x == 'U' and K: K -= 1 KU += 1 elif x == 'R' and KU: KU -= 1 KUR += 1 elif x == 'O' and KUR: KUR -= 1 KURO += 1 elif x == 'I' and KURO: KURO -= 1 KUROI += 1 return KUROI answer = 0 for a, e, b, c in itertools.product(range(21), range(21), range(101), range(101)): d = ques - (a + b + c + e) if d < 0: continue x = solve(a, b, c, d, e) if answer < x: answer = x print(answer)