結果
| 問題 |
No.1211 円環はお断り
|
| コンテスト | |
| ユーザー |
Chanyuh
|
| 提出日時 | 2020-08-31 09:21:04 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,051 bytes |
| コンパイル時間 | 2,046 ms |
| コンパイル使用メモリ | 128,596 KB |
| 最終ジャッジ日時 | 2025-01-14 02:24:07 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 22 TLE * 19 |
ソースコード
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int n,k;
ll a[100010];
vector<ll> S;
bool check(ll x){
vector<vector<int>> table(2*n+2,vector<int>(18,0));
rep(i,2*n+1){
table[i][0]=lower_bound(S.begin(),S.end(),x+S[i])-S.begin();
//cout << i << " " << table[i][0] << endl;
}
rep(j,18){
table[2*n+1][j]=2*n+1;
}
rep(j,17){
rep(i,2*n+1){
table[i][j+1]=table[table[i][j]][j];
}
}
rep(i,n){
int pos=i;
rep(j,17){
if(k&(1 << j)) pos=table[pos][j];
}
if(pos<=i+n){
return true;
}
}
return false;
}
void solve(){
cin >> n >> k;
rep(i,n) cin >> a[i];
S.resize(2*n+2);
rep(i,n){
S[i+1]=S[i]+a[i];
}
rep(i,n){
S[i+n+1]=S[i+n]+a[i];
}
S[2*n+1]=INF;
ll l=0,r=INF;
while(r-l>1){
ll mid=(l+r)/2;
if(check(mid)) l=mid;
else r=mid;
}
cout << l << endl;
return;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(50);
solve();
}
Chanyuh