結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
hogeover30
|
| 提出日時 | 2015-02-10 22:38:08 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 518 bytes |
| コンパイル時間 | 532 ms |
| コンパイル使用メモリ | 59,040 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-06 17:03:22 |
| 合計ジャッジ時間 | 1,873 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 WA * 8 |
ソースコード
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int n, k;
string s;
while (cin>>n>>k>>s) {
int res=0, a=0;
for(int i=0;i<min(n,k);++i) {
a ? --a : ++res;
if (s[i]!='0') a+=s[i]-'0';
}
if (k<=n or a>=n) { cout<<res<<endl; continue; }
int x=res-a;
res+=(k-n)/n*x;
for(int i=0;i<k%n;++i) {
a ? --a : ++res;
if (s[i]!='0') a+=s[i]-'0';
}
cout<<res<<endl;
}
}
hogeover30