結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
![]() |
提出日時 | 2020-03-29 15:12:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 557 bytes |
コンパイル時間 | 1,553 ms |
コンパイル使用メモリ | 161,460 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-02 13:28:36 |
合計ジャッジ時間 | 2,465 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 WA * 9 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long template<typename T> void fin(T a){ cout<<a<<endl; exit(0); } signed main(){ int n,k;string s;cin>>n>>k>>s; int A=0;//1箱目を全部食べるために必要なお金 int B=0;//1箱目を全部食べた時に浮いたお金 for(int i=0;i<n;i++){ if(B==0)A++; else B--; if(i==k-1)fin(A); B+=s[i]-'0'; } if(A<=B)fin(A); int ans=0; ans+=A+(k/n-1)*(A-B); for(int i=0;i<k%n;i++){ if(B==0)A++; else B--; B+=s[i]-'0'; } cout<<ans<<endl; }