QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#221614#7617. Spectacleucup-team956#WA 1ms7692kbC++201.0kb2023-10-21 14:00:032023-10-21 14:00:03

Judging History

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

  • [2023-10-21 14:00:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7692kb
  • [2023-10-21 14:00:03]
  • 提交

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;
}

详细

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 '