結果
問題 | No.78 クジ付きアイスバー |
ユーザー |
![]() |
提出日時 | 2015-11-06 22:00:01 |
言語 | C++11 (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,711 bytes |
コンパイル時間 | 512 ms |
コンパイル使用メモリ | 73,408 KB |
実行使用メモリ | 10,016 KB |
最終ジャッジ日時 | 2024-10-06 18:31:52 |
合計ジャッジ時間 | 10,325 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 2 TLE * 1 -- * 32 |
ソースコード
#include <iostream> #include <algorithm> #include <vector> #include <queue> #include <map> #include <set> #include <cstdio> #include <cmath> #include <cstring> #include <string> #include <ctime> #include <cstdlib> #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define FFOR(i,a,b) for(int i=(a);i<=(b);i++) #define REP(i,b) FOR(i,0,b) #define RREP(i,b) FFOR(i,1,b) #define PB push_back #define F first #define S second #define BE(c) c.begin(),c.end() using namespace std; typedef long long LL; typedef LL ut; typedef long double ld; typedef pair<ut,ut> pr; typedef vector<pr> Vpr; typedef vector<ut> VI; typedef pair<ut,pr> ppr; typedef priority_queue<pr,Vpr, greater<pr> > PQ; const int SIZE=1e+5 + 1; const ut INF=1<<29; const ld eps=1e-6; const LL mod=1e+6 + 3; int main() { int n, k; string s; cin >> n >> k >> s; int now = 0, f = 0, cnt = 0; int ans = 0; bool end = false; do{ ans++; int c = s[now] - '0'; do { if(f > 0){ c = s[now] - '0'; f--; } if(c == 1){ f++; } else if(c == 2){ f += 2; } now++; cnt++; if(ans == 1 && now >= n && f != 0){ end = true; now = 0; break; } if(k <= cnt){ now = 0; break; } now %= n; }while(f != 0); }while(now != 0); if(end){ cout << ans << endl; return 0; } ans = ans * (k / cnt); int p = k % cnt; if(!p){ cout << ans << endl; return 0; } cnt = 0; end = false; do{ ans++; char c = s[now]; do { if(f > 0){ c = s[now]; f--; } if(c == '1'){ f++; } else if(c == '2'){ f += 2; } now++; cnt++; if(p <= cnt){ end = true; break; } now %= n; }while(f != 0); }while(!end); cout << ans << endl; return 0; }