QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#221146 | #7617. Spectacle | ucup-team022# | WA | 1ms | 11848kb | C++14 | 814b | 2023-10-21 10:12:15 | 2023-10-21 10:12:15 |
Judging History
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'