結果
| 問題 | No.78 クジ付きアイスバー |
| コンテスト | |
| ユーザー |
woodsgreen
|
| 提出日時 | 2022-01-13 01:29:34 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 476 bytes |
| 記録 | |
| コンパイル時間 | 1,434 ms |
| コンパイル使用メモリ | 209,416 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-24 23:55:54 |
| 合計ジャッジ時間 | 2,471 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 35 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int n,k,stock,cost;
char box[60];
void f(int rest){
for(int i=0;i<rest;i++){
if(stock>0)stock--;else cost++;
stock+=box[i]-'0';
}
}
int main(){
scanf("%d%d%s",&n,&k,box);
f(min(n,k));
if(k<n)
printf("%d",cost);
else
if(cost<=stock)
printf("%d",cost);
else{
cost+=(cost-stock)*(k/n-1);
f(k%n);
printf("%d",cost);
}
return 0;
}
woodsgreen