結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
spade630
|
| 提出日時 | 2015-11-06 21:53:33 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,704 bytes |
| コンパイル時間 | 726 ms |
| コンパイル使用メモリ | 73,412 KB |
| 実行使用メモリ | 8,448 KB |
| 最終ジャッジ日時 | 2024-10-06 18:31:03 |
| 合計ジャッジ時間 | 10,791 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| 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){
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;
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;
now = 0;
break;
}
now %= n;
}while(f != 0);
}while(now != 0);
cout << ans << endl;
return 0;
}
spade630