結果
| 問題 |
No.78 クジ付きアイスバー
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-30 10:50:32 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 501 bytes |
| コンパイル時間 | 2,387 ms |
| コンパイル使用メモリ | 193,264 KB |
| 最終ジャッジ日時 | 2025-01-10 19:16:20 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 31 TLE * 4 |
ソースコード
#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;
}