結果

問題 No.1211 円環はお断り
ユーザー 沙耶花沙耶花
提出日時 2020-08-30 14:38:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,034 bytes
コンパイル時間 2,160 ms
コンパイル使用メモリ 207,164 KB
実行使用メモリ 18,280 KB
最終ジャッジ日時 2024-04-27 07:39:04
合計ジャッジ時間 32,644 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 3 ms
6,940 KB
testcase_10 WA -
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 849 ms
11,008 KB
testcase_14 WA -
testcase_15 AC 1,070 ms
13,312 KB
testcase_16 AC 1,710 ms
17,940 KB
testcase_17 AC 123 ms
6,944 KB
testcase_18 WA -
testcase_19 AC 141 ms
6,944 KB
testcase_20 WA -
testcase_21 AC 159 ms
6,944 KB
testcase_22 AC 856 ms
11,292 KB
testcase_23 AC 967 ms
12,672 KB
testcase_24 AC 546 ms
8,644 KB
testcase_25 AC 29 ms
6,944 KB
testcase_26 AC 1,163 ms
14,080 KB
testcase_27 AC 570 ms
8,640 KB
testcase_28 WA -
testcase_29 AC 978 ms
12,060 KB
testcase_30 AC 1,223 ms
14,848 KB
testcase_31 AC 536 ms
8,004 KB
testcase_32 AC 1,524 ms
16,768 KB
testcase_33 AC 1,711 ms
18,084 KB
testcase_34 AC 1,717 ms
18,072 KB
testcase_35 AC 1,683 ms
18,084 KB
testcase_36 AC 1,618 ms
18,152 KB
testcase_37 AC 1,617 ms
18,176 KB
testcase_38 AC 1,647 ms
18,156 KB
testcase_39 AC 1,659 ms
18,280 KB
testcase_40 AC 1,450 ms
18,156 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 2000000000000000000

int main(){
	
	int N,K;
	cin>>N>>K;
	long long S = 0LL;
	vector<long long> A(N);
	for(int i=0;i<N;i++){
		cin>>A[i];
		S += A[i];
	}
	
	long long ok = 0LL,ng = S+1;
	
	while(ng-ok>1){
		long long mid = (ok+ng)/2;
		vector<vector<long long>> next(17,vector<long long>(N,0LL));
		S = 0LL;
		int cnt = 0;
		int pos = 0;
		for(int i=0;i<N;i++){
			while(S<mid){
				S += A[pos];
				pos++;
				pos%=N;
				cnt++;
			}
			next[0][i] = cnt;
			cnt--;
			S -= A[i];
		}
		
		for(int i=1;i<17;i++){
			for(int j=0;j<N;j++){
				next[i][j] = next[i-1][j] + next[i-1][(j+next[i-1][j])%N];
			}
		}
		
		vector<long long> X(N,0LL);
		for(int i=0;i<17;i++){
			if((K>>i)&1){
				for(int j=0;j<N;j++){
					X[j] += next[i][X[j]%N];
				}
			}
		}
		bool f = false;
		for(int i=0;i<N;i++){
			if(X[i]<=N)f=true;
		}
		if(f)ok = mid;
		else ng = mid;
	}
	
	cout<<ok<<endl;
	
	return 0;
}
0