結果

問題 No.78 クジ付きアイスバー
ユーザー pluto77
提出日時 2016-09-30 10:52:31
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 346 bytes
コンパイル時間 44 ms
コンパイル使用メモリ 7,040 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-21 11:10:03
合計ジャッジ時間 1,526 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki_78

n,k=map(int,raw_input().split())
s=raw_input()
res=0
point=cost=0
if k>=n:
 for i in xrange(n):
  if point==0:
   cost+=1
  else:
   point-=1
  point+=int(s[i])
 res+=cost
 k=k-n
 res+=k/n*max(cost-point,0)

cost2=0
point2=point
for i in xrange(k%n):
 if point2==0:
  cost2+=1
 else:
  point2-=1
 point2+=int(s[i])
res+=cost2
print res
0