QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#401720#7617. SpectacleAndevikingTL 0ms3792kbC++20962b2024-04-29 10:58:322024-04-29 10:58:32

Judging History

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

  • [2024-04-29 10:58:32]
  • 评测
  • 测评结果:TL
  • 用时:0ms
  • 内存:3792kb
  • [2024-04-29 10:58:32]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define range(x) (x).begin(),(x).end()
const int dir[][2]={1,0,-1,0,0,1,0,-1};

void solve()
{
    int n;
    cin>>n;
    vector<ll>v(n);
    for(auto&  c:v)
        cin>>c;
    sort(range(v));

    for(int k=1;k<=n/2;++k){
        ll l=0,r=1E18;
        while(l<r){
            ll mid=(l+r)>>1;
            vector<int>vis(n);
        
            int cnt=0;
            for(int i=1;i<n;++i)
                if(v[i]-v[i-1]<=mid&&!vis[i-1]){
                    vis[i]=1;
                    cnt++;
                }
            if(cnt>=k)
                r=mid;
            else
                l=mid+1;
        }

        

        cout<<l<<' ';
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3528kb

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

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: