結果
| 問題 |
No.3266 岩井星人は見ずにはいられない
|
| コンテスト | |
| ユーザー |
detteiuu
|
| 提出日時 | 2025-09-06 14:51:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 755 bytes |
| コンパイル時間 | 360 ms |
| コンパイル使用メモリ | 82,964 KB |
| 実行使用メモリ | 661,604 KB |
| 最終ジャッジ日時 | 2025-09-06 14:51:39 |
| 合計ジャッジ時間 | 4,632 ms |
|
ジャッジサーバーID (参考情報) |
judge / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 10 MLE * 1 -- * 20 |
ソースコード
N, A = map(int, input().split())
S = input()
MAX = 0
cnt = 0
for s in S:
if s == "0":
cnt -= 1
else:
cnt += 1
MAX = max(MAX, cnt)
limit = 1200-MAX
cnt1 = S.count("1")
visited = set()
rate = 1200
now = 0
ans = 0
while rate not in visited:
visited.add(rate)
c = max(rate-limit, 0)
if A <= now+(cnt1-c):
break
ans += N
now += cnt1-c
rate += cnt1-(N-cnt1)-c
if rate in visited:
c = max(rate-limit, 0)
cnt = (A-now-1)//(cnt1-c)
ans += N*cnt
now += (cnt1-c)*cnt
rate += (cnt1-(N-cnt1)-c)*cnt
for s in S:
ans += 1
if s == "0":
rate -= 1
else:
if rate < 1200:
rate += 1
now += 1
if now == A:
print(ans)
break
detteiuu