21572022-12-26 18:43:35bzsofiaTalálkozáscpp11Wrong answer 9/5582ms8028 KiB
#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

struct adat
{
    int jon, megy;
};

int i, n, j, mini, minj, tav;
priority_queue <pair <int, int>> mp;

bool comp(adat a, adat b)
{
    if (a.megy==b.megy) return a.jon<b.jon;

    return a.megy<b.megy;
}

int main()
{
    //ifstream fin("be.in"); fin>>n;
    cin>>n;
    tav=n+1;
    int fele=n/2+n%2;
    vector <adat> x(n+1);

    for (i=1; i<=n; ++i)
    {
        cin>>x[i].jon>>x[i].megy;
    }

    sort(x.begin()+1, x.end(), comp);

    for (i=1; i<fele; ++i)
        mp.push({x[i].jon, i});

    for (i=fele; i<=n; ++i)
    {
        mp.push({x[i].jon, i});

        while (!mp.empty() && mp.top().second<i-fele+1)
            mp.pop();

        //cout<<x[i-n/2+1].megy<<" "<<mp.top().first<<"\n";
        if (mp.top().first<=x[i-fele+1].megy)
        {
            tav=1;
            minj=mini=mp.top().first;
        }else if (tav>mp.top().first-x[i-fele+1].megy+1)
        {
            tav=mp.top().first-x[i-fele+1].megy+1;
            mini=x[i-fele+1].megy;
            minj=mp.top().first;
        }
    }

    cout<<tav<<"\n"<<mini<<" "<<minj;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base9/55
1Accepted0/03ms1816 KiB
2Wrong answer0/082ms5580 KiB
3Partially correct1/22ms2228 KiB
4Accepted2/22ms2280 KiB
5Accepted2/22ms2484 KiB
6Wrong answer0/22ms2568 KiB
7Wrong answer0/22ms2696 KiB
8Wrong answer0/32ms2892 KiB
9Wrong answer0/32ms2976 KiB
10Wrong answer0/32ms3240 KiB
11Wrong answer0/37ms3576 KiB
12Wrong answer0/38ms3952 KiB
13Wrong answer0/38ms4084 KiB
14Wrong answer0/316ms4464 KiB
15Wrong answer0/316ms4592 KiB
16Wrong answer0/316ms4924 KiB
17Wrong answer0/316ms5048 KiB
18Wrong answer0/325ms5476 KiB
19Partially correct1/382ms8028 KiB
20Accepted3/372ms8024 KiB
21Wrong answer0/382ms8028 KiB
22Wrong answer0/382ms8024 KiB