結果

問題 No.78 クジ付きアイスバー
ユーザー fantasiabaetica
提出日時 2018-06-29 14:39:20
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 886 bytes
コンパイル時間 505 ms
コンパイル使用メモリ 66,560 KB
実行使用メモリ 506,028 KB
最終ジャッジ日時 2024-06-30 23:47:39
合計ジャッジ時間 7,035 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other WA * 1 OLE * 1 -- * 33
権限があれば一括ダウンロードができます

ソースコード

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];
    string ices;
    cin >> ices;
    for (int i = 0; i < n; i++){
        int ice = ices[i] - '0';
        for (int j = 0; i + (n * j) < k; j++){
            cout << i + (n * j) << "ngo" << endl;
            box[i + (n * j)] = ice;
        }
    }
    for (int i = 0; i < k; i++){
        cout << box[i] << " ";
    }
    int cost = buy_ice(k % n, box);
    cout << cost << endl;
    
    return 0;
}
0