結果
問題 | No.78 クジ付きアイスバー |
ユーザー |
![]() |
提出日時 | 2014-11-27 00:05:55 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 611 bytes |
コンパイル時間 | 491 ms |
コンパイル使用メモリ | 62,080 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 00:25:45 |
合計ジャッジ時間 | 1,635 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 |
ソースコード
#include <iostream> #include <algorithm> #include <cstdio> #include <cstdlib> #include <sstream> #include <cstring> #include <string> #include <vector> #define rep(x,to) for(int (x)=0;(x)<(to);(x)++) using namespace std; typedef long long ll; int main() { int n, k; string s; cin >> n >> k >>s; int at=0, res=0; rep(i,n) at += s[i]-'0'; int wt = max(0, (k-5000)/n); res = max(0, wt * (n-at)); at =0; k -= n * wt; while(k>0){ rep(i,n){ if(at>0) at--; else res++; k--; if(k < 1) break; at += s[i] -'0'; } } cout << res << endl; return 0; }