結果
| 問題 | No.78 クジ付きアイスバー |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-29 13:42:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,005 bytes |
| 記録 | |
| コンパイル時間 | 490 ms |
| コンパイル使用メモリ | 64,276 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 23:46:40 |
| 合計ジャッジ時間 | 1,572 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 4 |
| other | AC * 1 WA * 34 |
ソースコード
#include <iostream>
using namespace std;
int buy_ice_box(int n, int *box){
int cost = 0;
int free = 0;
for (int i = 0; i < n; 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 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(){
int n, k;
cin >> n >> k;
int box[n];
int cost_sum = 0;
int cost_box = buy_ice_box(n, box);
cost_sum += (k / n) * cost_box;
cost_sum += buy_ice(k % n, box);
cout << cost_sum << endl;
return 0;
}