QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#224760#7617. Spectacleucup-team004#TL 1ms5740kbC++20939b2023-10-23 13:42:152023-10-23 13:42:16

Judging History

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

  • [2023-10-23 13:42:16]
  • 评测
  • 测评结果:TL
  • 用时:1ms
  • 内存:5740kb
  • [2023-10-23 13:42:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
const int N=200005;
const ll inf=1e18;
int t,n;
ll a[N],ans[N];
void solve(int l,int r,ll L,ll R){
    if(l>r)return;
    if(L==R){
        For(i,l,r)ans[i]=L; return;
    }
    ll mid=(L+R)>>1;
    int cnt=0;
    For(i,1,n-1){
        if(a[i+1]-a[i]<=mid){
            cnt++; i++;
        }
    }
    solve(l,cnt,L,mid);
    solve(cnt+1,r,mid+1,R);
}
int main(){
    ios::sync_with_stdio(0);cin.tie(0);
    t=1;
    while(t--){
        cin>>n;
        For(i,1,n){
            cin>>a[i];
        }
        sort(a+1,a+n+1);
        /*int l=0,r=n-1;
        while(l<r){
            int mid=(l+r)>>1; mid++;
            if(check(mid))l=mid; else r=mid-1;
        }
        cout<<n-l<<endl;*/
        solve(1,n/2,0,inf);
        For(i,1,n/2)cout<<ans[i]<<(i<n/2?' ':'\n');
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5740kb

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: 1ms
memory: 5648kb

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: