結果
問題 |
No.935 う し た ぷ に き あ く ん 笑 ビ - ム
|
ユーザー |
|
提出日時 | 2021-10-31 12:29:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 665 ms / 2,000 ms |
コード長 | 812 bytes |
コンパイル時間 | 401 ms |
コンパイル使用メモリ | 82,332 KB |
実行使用メモリ | 77,088 KB |
最終ジャッジ日時 | 2024-10-08 16:34:28 |
合計ジャッジ時間 | 17,064 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 58 |
ソースコード
def binary_search_int(ok, ng, test): """ :param ok: solve(x) = True を必ず満たす点 :param ng: solve(x) = False を必ず満たす点 """ while abs(ok - ng) > 1: mid = (ok + ng) // 2 if test(mid): ok = mid else: ng = mid return ok ############################################################## import sys input = sys.stdin.readline N=int(input()) S=input().rstrip() A=list(map(int, input().split())) Q=int(input()) K=list(map(int, input().split())) SS=[0] for s in S: SS.append(SS[-1]+(s=="E")) SA=[0] for a in A: SA.append(SA[-1]+a) for k in K: res=0 for i in range(N): def test(x): return SA[x]-SA[i]<=k r=binary_search_int(i,N+1,test) res=max(SS[r]-SS[i],res) print(res)