結果

問題 No.78 クジ付きアイスバー
コンテスト
ユーザー Tawara
提出日時 2015-10-21 01:14:40
言語 PyPy2
(7.3.15)
結果
AC  
実行時間 78 ms / 5,000 ms
コード長 311 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 240 ms
コンパイル使用メモリ 77,720 KB
最終ジャッジ日時 2025-12-03 17:40:17
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N,K = map(int,raw_input().split())
S = raw_input()
need = [0]*(N+1)
luck = 0
for i in xrange(N):
	need[i+1] = need[i]
	if luck == 0:
		need[i+1] += 1
	else:
		luck -= 1
	luck += int(S[i])
m = K/N
if m < 1:
	print need[K]	
else:
	print need[N] if luck >= need[N] else need[N]*m-luck*(m-1) + max(0,need[K%N]-luck)
0