結果

問題 No.78 クジ付きアイスバー
ユーザー spade630spade630
提出日時 2015-11-06 21:53:33
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,704 bytes
コンパイル時間 844 ms
コンパイル使用メモリ 73,580 KB
実行使用メモリ 10,144 KB
最終ジャッジ日時 2024-04-16 05:46:12
合計ジャッジ時間 10,762 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,012 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 WA -
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 3,630 ms
6,944 KB
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0