QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#221614 | #7617. Spectacle | ucup-team956# | WA | 1ms | 7692kb | C++20 | 1.0kb | 2023-10-21 14:00:03 | 2023-10-21 14:00:03 |
Judging History
answer
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i <= b; ++i)
using namespace std;
#define int long long
const int _ = 2e6+6;
const int inf=0x3f3f3f3f;
int n,a[_],tot,f[_],siz[_];
int find(int x) {return x==f[x] ? x : f[x]=find(f[x]);}
void uu(int x,int y) {
x=find(x),y=find(y);
if(x==y) return;
tot-=(siz[x]+1)/2;
tot-=(siz[y]+1)/2;
siz[y]+=siz[x];
f[x]=y;
tot+=(siz[y]+1)/2;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
FOR(i,1,n) cin>>a[i];
sort(a+1,a+1+n);
FOR(i,1,n) f[i]=i,siz[i]=1;
vector<array<int,2>> b;
vector<int> vis(n+1),ans(n+10,inf);
FOR(i,1,n-1) b.push_back({abs(a[i+1]-a[i]),i});
sort(b.begin(),b.end());
for(auto [val,id]:b) {
vis[id]=1;tot++;
if(vis[id-1]) uu(id-1,id);
if(vis[id+1]) uu(id+1,id);
ans[min(tot,n/2)]=min(ans[min(tot,n/2)],val);
}
for(int i=n/2;i>=1;--i) ans[i]=min(ans[i],ans[i+1]);
FOR(i,1,n/2) cout<<ans[i]<<" ";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 7692kb
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: 7684kb
input:
2 1 1000000000000000000
output:
1061109567
result:
wrong answer 1st lines differ - expected: '999999999999999999', found: '1061109567 '