結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
|
提出日時 | 2017-02-23 11:01:10 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 837 bytes |
コンパイル時間 | 1,676 ms |
コンパイル使用メモリ | 158,084 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2025-01-02 18:14:49 |
合計ジャッジ時間 | 3,023 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 2 |
other | AC * 29 WA * 6 |
ソースコード
#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; } }