結果

問題 No.78 クジ付きアイスバー
ユーザー DialBirdDialBird
提出日時 2017-02-23 11:01:10
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 837 bytes
コンパイル時間 1,375 ms
コンパイル使用メモリ 145,836 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-30 21:17:38
合計ジャッジ時間 2,850 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 WA -
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1 ms
4,376 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

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 box_buy = 0;
  int box_atari = 0;
  vector<int> necessary_buys(N);

  REP(i,0,N){
    if (box_atari > 0) {
      --box_atari;
    } else {
      ++box_buy;
    }
    necessary_buys[i] = box_buy;
    box_atari += ice_box[i] - '0';
  }

  if (K < N) {
    cout << necessary_buys[K % N] << endl;
  } else {
    int interval_buy = MAX(0, box_buy - box_atari);
    int last_buy = MAX(0, necessary_buys[K % N] - box_atari);
    cout << box_buy + ((K / N) - 1) * interval_buy + last_buy << endl;
  }
}
0