QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#315182#7617. Spectaclethomas_li#TL 0ms3596kbC++171.2kb2024-01-27 02:29:362024-01-27 02:29:37

Judging History

你现在查看的是最新测评结果

  • [2024-01-27 02:29:37]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3596kb
  • [2024-01-27 02:29:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i,a,b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back
#define FS first
#define SD second
#define ary(k) array<int,k>
template<class A, class B> void cmx(A& x, B y){ x = max<A>(x,y); }
template<class A, class B> void cmn(A& x, B y){ x = min<A>(x,y); }
typedef pair<int,int> pii;
typedef vector<int> vi;

signed main(){
	cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
	int n; cin >> n;
	vi a(n); for(int& v : a) cin >> v;
	sort(all(a));
	vi ans(n/2);
	auto rec = [&](auto&& rec, int l, int r, vi& cur)->void{
		if(!sz(cur)) return;
		if(l == r){
			for(int x : cur) ans[x-1] = l;
			return;
		}
		int mid = (l+r)/2;
		auto f = [&](int i){
			return a[i+1]-a[i] <= mid;
		};
		int mx = 0;
		rep(i,0,n-1) if(f(i)){
			int j = i;
			while(j+1 < n-1 && f(j+1)) j++;
			int len = j-i+1;
			mx += (len+1)/2;
			i = j;
		}
		vi lft,rit;
		for(int x : cur){
			if(x <= mx) lft.PB(x);
			else rit.PB(x);
		}
		rec(rec,l,mid,lft);
		rec(rec,mid+1,r,rit);
	};
	vi pos(n/2); iota(all(pos),1);
	rec(rec,0,1e18,pos);
	rep(i,0,n/2) cout << ans[i] << " \n"[i==n/2-1];	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3592kb

input:

6
100 13 20 14 10 105

output:

1 5 6

result:

ok single line: '1 5 6'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

2
1 1000000000000000000

output:

999999999999999999

result:

ok single line: '999999999999999999'

Test #3:

score: -100
Time Limit Exceeded

input:

200000
30977570544127554 30977570529630987 30977570554040634 30977570903666181 30977570284338326 30977570675313216 30977569987827221 30977570780807305 30977570623822067 30977570207823010 30977569932624714 30977570440962037 30977570343703869 30977570239637322 30977570141845422 30977570372368100 30977...

output:


result: