結果

問題 No.78 クジ付きアイスバー
ユーザー DialBird
提出日時 2017-02-23 09:51:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 561 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 156,448 KB
実行使用メモリ 13,768 KB
最終ジャッジ日時 2025-01-02 18:11:51
合計ジャッジ時間 128,888 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 18 TLE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

int N, K;

int main(){
  cin >> N >> K;
  vector<char> ice_box(N);

  REP(i,0,N){
    cin >> ice_box[i];
  }

  int atari = 0;
  int buy = 0;
  int idx = 0;
  int eat = 0;

  while (true) {
    idx %= N;
    if (atari > 0) {
      --atari;
    } else {
      ++buy;
    }
    ++eat;

    atari += ice_box[idx] - '0';
    if (eat + atari >= K) break;

    ++idx;
  }

  cout << buy << endl;
}
0