結果

問題 No.78 クジ付きアイスバー
コンテスト
ユーザー DialBird
提出日時 2017-02-23 09:51:01
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 561 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,523 ms
コンパイル使用メモリ 176,128 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-06 05:54:35
合計ジャッジ時間 19,008 ms
ジャッジサーバーID
(参考情報)
judge1_1 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 5 TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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