結果

問題 No.78 クジ付きアイスバー
ユーザー furafura
提出日時 2020-05-30 10:50:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 501 bytes
コンパイル時間 2,230 ms
コンパイル使用メモリ 195,304 KB
実行使用メモリ 8,704 KB
最終ジャッジ日時 2024-04-24 21:25:28
合計ジャッジ時間 20,395 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 TLE -
testcase_06 AC 2 ms
5,376 KB
testcase_07 TLE -
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	int n,k;
	string s; cin>>n>>k>>s;

	vector<int> sum(n+1);
	rep(i,n) sum[i+1]=sum[i]+(s[i]-'0');

	lint lo=0,hi=k;
	while(hi-lo>1){
		lint mi=(lo+hi)/2;

		lint cnt=0,x=mi;
		while(x>0 && cnt<k){
			lint c1=sum[n]*(cnt/n)+sum[cnt%n];
			cnt+=x;
			lint c2=sum[n]*(cnt/n)+sum[cnt%n];
			x=c2-c1;
		}
		if(cnt>=k) hi=mi;
		else       lo=mi;
	}
	printf("%lld\n",hi);

	return 0;
}
0