結果
問題 | No.78 クジ付きアイスバー |
ユーザー |
|
提出日時 | 2019-08-23 02:25:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 627 bytes |
コンパイル時間 | 2,016 ms |
コンパイル使用メモリ | 193,172 KB |
最終ジャッジ日時 | 2025-01-07 14:40:16 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n,k;string s; cin>>n>>k>>s; int buy=0,stock=0; for (int i=0;i<n;i++) { if (stock>0) stock--; else buy++; k--; if (k==0) { cout<<buy<<endl; return 0; } stock+=s[i]-'0'; } if (buy<=stock) { cout<<buy<<endl; return 0; } int buyperbox=buy-stock; buy+=k/n*buyperbox; k%=n; for (int i=0;i<k;i++) { if (stock>0) stock--; else buy++; stock+=s[i]-'0'; } cout<<buy<<endl; return 0; }