QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#221536#7617. Spectacleucup-team956#TL 0ms5676kbC++20796b2023-10-21 13:41:502023-10-21 13:41:51

Judging History

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

  • [2023-10-21 13:41:51]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:5676kb
  • [2023-10-21 13:41:50]
  • 提交

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[_],ans[_];
int check(int mid) {
    int ans=0;
    FOR(i,1,n-1) {
        if((a[i+1]-a[i])<=mid) {
            ans++;
            i++;
        }
    }
    return ans;
}
void solve(int l,int r,int x,int y) {
    if(l>r||x>y) return;
    if(x==y) {
        FOR(i,l,r) ans[i]=x;
        return;
    }
    int mid=(x+y)/2,val=check(mid);
    solve(l,val,x,mid);
    solve(val+1,r,mid+1,y);
}
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);
    solve(1,n/2,0,1e18);
    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: 0ms
memory: 5668kb

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: 5676kb

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: