結果

問題 No.78 クジ付きアイスバー
ユーザー cureskol
提出日時 2020-03-29 15:08:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 535 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 160,728 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-02 13:28:16
合計ジャッジ時間 2,852 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int n,k;string s;cin>>n>>k>>s;
  int A=0;//1箱目を全部食べるために必要なお金
  int B=0;//1箱目を全部食べた時に浮いたお金
  for(int i=0;i<n;i++){
    if(B==0)A++;
    else B--;
    if(i==k-1)fin(A);
    B+=s[i]-'0';
  }
  if(A<=B)fin(A);
  int ans=0;
  ans+=A+(k/n-1)*(A-B);
  for(int i=0;i<k%n;i++){
    if(B==0)A++;
    else B--;
    B+=s[i]-'0';
  }
  cout<<ans<<endl;
}
0