結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
|
提出日時 | 2016-03-30 15:16:41 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 817 bytes |
コンパイル時間 | 740 ms |
コンパイル使用メモリ | 65,872 KB |
実行使用メモリ | 9,892 KB |
最終ジャッジ日時 | 2024-10-06 19:05:15 |
合計ジャッジ時間 | 10,061 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 2 TLE * 1 -- * 32 |
ソースコード
#include <iostream> #include <queue> #include <vector> int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n, k; std::cin >> n >> k; std::vector<char> s(n); std::queue<int> iceQueue; for(int i=0; i<n; ++i){ std::cin >> s[i]; } auto FillQueue = [&]{ static auto it = s.begin(); while(static_cast<int>(iceQueue.size()) <= n){ iceQueue.push((*it)-'0'); ++it; if(it==s.end()) it=s.begin(); } }; int buyNum = 0; int freeNum = 0; for(int i=0; i<k; ++i){ FillQueue(); if(freeNum == 0){ ++buyNum; }else{ --freeNum; } freeNum += iceQueue.front(); iceQueue.pop(); } std::cout << buyNum << "\n"; return 0; }