結果

問題 No.78 クジ付きアイスバー
ユーザー fantasiabaeticafantasiabaetica
提出日時 2018-06-29 14:19:35
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 720 bytes
コンパイル時間 2,008 ms
コンパイル使用メモリ 51,828 KB
実行使用メモリ 814,000 KB
最終ジャッジ日時 2023-09-13 15:09:52
合計ジャッジ時間 6,731 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
typedef long long int ll;
using namespace std;

int buy_ice(int k, int *box){
    int cost = 0;
    int free = 0;
    for (int i = 0; i < k; i++){
        int ice = box[i];
        if (free > 0){
            free -= 1;
        } else {
            cost += 1;
        }
        if (ice == 2){
            free += 2;
        } else if (ice == 1){
            free += 1;
        } 
    }
    return cost;
}

int main(){
    ll n, k;
    cin >> n >> k;
    int box[k];
    char c;
    for (int i = 0; i < n; i++){
        cin >> c;
        for (int j = 0; i + n * j < k; j++){
            box[j] = (int)c;
        }
    }
    int cost = buy_ice(k % n, box);
    cout << cost << endl;
    
    return 0;
}
0