結果

問題 No.1211 円環はお断り
ユーザー chocorusk
提出日時 2020-08-30 22:44:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 957 ms / 2,000 ms
コード長 1,303 bytes
コンパイル時間 1,456 ms
コンパイル使用メモリ 123,048 KB
最終ジャッジ日時 2025-01-14 02:11:48
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int main()
{
int n, k; cin>>n>>k;
ll a[200020];
ll s[200020];
for(int i=0; i<n; i++){
cin>>a[i];
a[i+n]=a[i];
}
s[0]=0;
for(int i=0; i<2*n; i++) s[i+1]=s[i]+a[i];
ll l=1, r=1.1e14;
while(r-l>1){
ll m=(l+r)/2;
if(m>s[n]){
r=m;
continue;
}
int nx[17][200020];
nx[0][2*n]=2*n;
for(int i=0; i<2*n; i++){
nx[0][i]=lower_bound(s, s+2*n, s[i]+m)-s;
}
for(int i=1; i<17; i++){
nx[i][2*n]=2*n;
for(int j=0; j<2*n; j++){
nx[i][j]=nx[i-1][nx[i-1][j]];
}
}
bool ok=0;
for(int i=0; i<n; i++){
int t=i;
for(int j=16; j>=0; j--){
if(k&(1<<j)){
t=nx[j][t];
}
}
if(t<=i+n){
ok=1; break;
}
}
if(ok) l=m;
else r=m;
}
cout<<l<<endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0