結果

問題 No.2221 Set X
ユーザー 沙耶花沙耶花
提出日時 2023-02-17 22:48:17
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 919 bytes
コンパイル時間 4,437 ms
コンパイル使用メモリ 266,032 KB
実行使用メモリ 14,124 KB
最終ジャッジ日時 2023-09-26 20:07:58
合計ジャッジ時間 7,733 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 24 ms
6,800 KB
testcase_17 AC 10 ms
4,376 KB
testcase_18 AC 28 ms
7,136 KB
testcase_19 AC 8 ms
4,432 KB
testcase_20 AC 16 ms
5,596 KB
testcase_21 AC 53 ms
8,916 KB
testcase_22 AC 74 ms
10,448 KB
testcase_23 AC 4 ms
4,380 KB
testcase_24 AC 48 ms
8,836 KB
testcase_25 AC 31 ms
6,440 KB
testcase_26 AC 66 ms
13,420 KB
testcase_27 AC 76 ms
13,468 KB
testcase_28 AC 76 ms
13,416 KB
testcase_29 AC 78 ms
13,472 KB
testcase_30 AC 73 ms
13,096 KB
testcase_31 AC 76 ms
13,492 KB
testcase_32 AC 78 ms
13,500 KB
testcase_33 AC 101 ms
13,676 KB
testcase_34 AC 93 ms
14,124 KB
testcase_35 AC 88 ms
13,752 KB
testcase_36 AC 78 ms
13,404 KB
testcase_37 AC 78 ms
13,380 KB
testcase_38 AC 78 ms
13,364 KB
testcase_39 AC 64 ms
12,564 KB
testcase_40 AC 72 ms
12,500 KB
testcase_41 AC 74 ms
13,080 KB
testcase_42 AC 75 ms
13,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 1000000000000000001


int main(){
	
	
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n)cin>>a[i];
	
	set<int> S;
	rep(i,n+1){
		S.insert(i);
	}
	vector<vector<int>> del(n*2);
	rep(i,n-1){
		int d = a[i+1] - a[i] + 1;
		if(d >= n*2)continue;
		del[d].push_back(i+1);
	}
	
	long long ans = n*2;
	int X = 1;
	for(int i=1;i<n*2;i++){
		
		rep(j,del[i].size())S.erase(del[i][j]);
		if((long long)(i+1) * (S.size()-1) > ans)continue;
		auto it = S.begin();
		long long sum = S.size()-1;
		while(true){
			if((*it)==n)break;
			sum -= a[(*it)] / i;
			it++;
			sum += a[(*it)-1] / i;
		}
		if(ans > sum * (i+1)){
			ans = sum * (i+1);
			X = i;
		}
	}
	cout<<X<<endl;
	cout<<ans<<endl;
	
	return 0;
}
0