結果
問題 | No.252 "良問"(良問とは言っていない (2) |
ユーザー | maspy |
提出日時 | 2020-03-07 01:14:30 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 1,316 ms / 2,000 ms |
コード長 | 866 bytes |
コンパイル時間 | 360 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 76,104 KB |
最終ジャッジ日時 | 2024-04-22 11:40:14 |
合計ジャッジ時間 | 6,972 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 678 ms
60,288 KB |
testcase_01 | AC | 1,316 ms
69,004 KB |
testcase_02 | AC | 656 ms
62,720 KB |
testcase_03 | AC | 655 ms
76,104 KB |
testcase_04 | AC | 663 ms
75,664 KB |
testcase_05 | AC | 660 ms
75,600 KB |
testcase_06 | AC | 526 ms
43,748 KB |
ソースコード
#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np # %% T = int(readline()) S = np.array(list(read().rstrip()), dtype=np.int8) # %% G = np.zeros(len(S), dtype=np.int64) P = np.zeros(len(S), dtype=np.int64) for i, ch in enumerate(b'problem'): P[:-6] += (S[i: len(S) - 6 + i] != ch) for i, ch in enumerate(b'good'): G[:-4] += (S[i: len(S) - 4 + i] != ch) ind = np.where(S == ord('\n'))[0] Ss = np.split(S, ind) Gs = np.split(G, ind) Ps = np.split(P, ind) # %% def solve(S, G, P): if S[0] == ord('\n'): S = S[1:] G = G[1:] P = P[1:] G[7:] += np.cumsum(P[:-7] == 0) G = np.minimum.accumulate(G[:-10]) cost = G + P[4:-6] return cost.min() for S, G, P in zip(Ss, Gs, Ps): print(solve(S, G, P))