QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#221146#7617. Spectacleucup-team022#WA 1ms11848kbC++14814b2023-10-21 10:12:152023-10-21 10:12:15

Judging History

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

  • [2023-10-21 10:12:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:11848kb
  • [2023-10-21 10:12:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=4e5+5;
int n;
LL a[N],ans[N];
pair<LL,int>b[N];
int fa[N],sz[N];
inline int find(int x){while(x!=fa[x])x=fa[x]=fa[fa[x]];return x;}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;++i)cin>>a[i];
	sort(a+1,a+n+1);
	for(int i=1;i<n;++i)b[i]=make_pair(a[i+1]-a[i],i);
	sort(b+1,b+n+1);
	for(int i=1;i<=n;++i)fa[i]=i,sz[i]=1;
	int nw=0,pre=0;
	memset(ans,0x3f,sizeof ans);
	for(int i=1;i<n;++i){
		int x=b[i].second,y=b[i].second+1;
		x=find(x),y=find(y);
		nw-=sz[x]/2+sz[y]/2;
		sz[x]+=sz[y],fa[y]=x;
		nw+=sz[x]/2;
		while(pre<nw){
			++pre;
			ans[pre]=b[i].first;
		}
		if(pre>=n/2)break;
	}
	for(int i=1;i<=n/2;++i)
		cout<<ans[i]<<" \n"[i==n/2];
	return 0;
}

详细

Test #1:

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

input:

6
100 13 20 14 10 105

output:

1 5 6

result:

ok single line: '1 5 6'

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 11820kb

input:

2
1 1000000000000000000

output:

4557430888798830399

result:

wrong answer 1st lines differ - expected: '999999999999999999', found: '4557430888798830399'