結果

問題 No.78 クジ付きアイスバー
ユーザー kotatsugamekotatsugame
提出日時 2019-10-12 06:02:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 420 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 64,352 KB
実行使用メモリ 8,760 KB
最終ジャッジ日時 2023-08-18 02:09:11
合計ジャッジ時間 17,768 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
7,944 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 TLE -
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 4,930 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 TLE -
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 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
		while(T<K)
		{
			long now=f(T);
			if(now==pre)break;
			T+=now-pre;
			pre=now;
		}
		if(T<K)L=M;
		else R=M;
	}
	cout<<R<<endl;
}
0