結果
問題 |
No.78 クジ付きアイスバー
|
ユーザー |
![]() |
提出日時 | 2015-06-20 23:22:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 563 bytes |
コンパイル時間 | 1,422 ms |
コンパイル使用メモリ | 158,156 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-06 17:07:10 |
合計ジャッジ時間 | 2,567 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 24 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; int n,k; string s; int passto; int simurate(int pass,int end){ int ans=0; for(int i=0;i<end;i++){ if(pass) pass--; else ans++; if(s[i]=='1') pass++; else if(s[i]=='2') pass+=2; } passto=pass; return ans; } int main(){ cin>>n>>k; cin>>s; int how=k%n; if(how==0) how=n; int start=simurate(0,how); if(k>n){ int cnt=0; for(int i=0;i<n;i++){ if(s[i]=='1') cnt++; else if(s[i]=='2') cnt+=2; } int need=0; if(cnt<n) need=n-cnt; start+=need*((k-1)/n); } cout<<start<<endl; return 0; }