結果

問題 No.1211 円環はお断り
ユーザー 👑 kmjpkmjp
提出日時 2022-02-12 00:24:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 286 ms / 2,000 ms
コード長 1,313 bytes
コンパイル時間 1,995 ms
コンパイル使用メモリ 200,016 KB
実行使用メモリ 13,928 KB
最終ジャッジ日時 2023-09-10 07:46:04
合計ジャッジ時間 8,463 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
9,916 KB
testcase_01 AC 3 ms
9,848 KB
testcase_02 AC 3 ms
9,892 KB
testcase_03 AC 3 ms
9,856 KB
testcase_04 AC 3 ms
10,048 KB
testcase_05 AC 3 ms
9,848 KB
testcase_06 AC 3 ms
9,892 KB
testcase_07 AC 4 ms
9,920 KB
testcase_08 AC 3 ms
9,908 KB
testcase_09 AC 4 ms
9,964 KB
testcase_10 AC 4 ms
9,940 KB
testcase_11 AC 4 ms
9,856 KB
testcase_12 AC 3 ms
9,936 KB
testcase_13 AC 151 ms
11,940 KB
testcase_14 AC 195 ms
12,708 KB
testcase_15 AC 189 ms
12,824 KB
testcase_16 AC 286 ms
13,848 KB
testcase_17 AC 29 ms
10,376 KB
testcase_18 AC 197 ms
12,316 KB
testcase_19 AC 29 ms
10,348 KB
testcase_20 AC 38 ms
10,448 KB
testcase_21 AC 33 ms
10,512 KB
testcase_22 AC 152 ms
12,028 KB
testcase_23 AC 161 ms
12,476 KB
testcase_24 AC 92 ms
11,320 KB
testcase_25 AC 10 ms
9,960 KB
testcase_26 AC 202 ms
12,828 KB
testcase_27 AC 96 ms
11,556 KB
testcase_28 AC 223 ms
12,892 KB
testcase_29 AC 165 ms
12,228 KB
testcase_30 AC 198 ms
13,012 KB
testcase_31 AC 99 ms
11,160 KB
testcase_32 AC 257 ms
13,760 KB
testcase_33 AC 271 ms
13,888 KB
testcase_34 AC 269 ms
13,864 KB
testcase_35 AC 267 ms
13,812 KB
testcase_36 AC 253 ms
13,928 KB
testcase_37 AC 250 ms
13,876 KB
testcase_38 AC 129 ms
13,824 KB
testcase_39 AC 123 ms
13,872 KB
testcase_40 AC 130 ms
13,868 KB
testcase_41 AC 4 ms
10,064 KB
testcase_42 AC 3 ms
9,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------


int N,K;
ll A[101010];
ll S[203030];

int nex[22][101010];
int nex2[101010];

int ok(ll v) {
	if(S[N]/K<v) return 0;
	
	int i,j,R=0;
	FOR(i,N) {
		while(S[R]<S[i]+v) R++;
		nex[0][i]=R-i;
	}
	ZERO(nex2);
	FOR(j,17) {
		FOR(i,N) nex[j+1][i]=min(N+1,nex[j][i]+nex[j][(i+nex[j][i])%N]);
		if(K&(1<<j)) {
			FOR(i,N) if(nex2[i]<N) nex2[i]+=nex[j][(i+nex2[i])%N];
		}
	}
	FOR(i,N) if(nex2[i]<=N) return 1;
	
	return 0;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	FOR(i,N) cin>>A[i];
	FOR(i,2*N) S[i+1]=S[i]+A[i%N];
	S[2*N+1]=1LL<<60;
	
	ll ret=0;
	for(i=50;i>=0;i--) if(ok(ret+(1LL<<i))) ret+=1LL<<i;
	cout<<ret<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0