結果

問題 No.78 クジ付きアイスバー
ユーザー kotatsugamekotatsugame
提出日時 2019-10-12 06:20:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 32 ms / 5,000 ms
コード長 452 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 64,480 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-18 02:38:44
合計ジャッジ時間 2,321 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 28 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 27 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 31 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 32 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 1 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 1 ms
4,380 KB
testcase_38 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:11:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   11 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
int N;
long K;
string s;
int sum[55];
long f(long X)
{
	return sum[N]*(X/N)+sum[X%N];
}
main()
{
	cin>>N>>K>>s;
	for(int i=0;i<N;i++)sum[i+1]=sum[i]+(s[i]=='0'?0:s[i]=='1'?1:2);
	long L=0,R=K;
	while(R-L>1)
	{
		long M=L+R>>1;
		long T=M,pre=0;
		int t=114514;
		while(T<K&&t--)
		{
			long now=f(T);
			if(now==pre)break;
			T+=now-pre;
			pre=now;
		}
		if(T<K&&pre==f(T))L=M;
		else R=M;
	}
	cout<<R<<endl;
}
0