21542022-12-26 18:20:40bzsofiaTalálkozáscpp11Wrong answer 5/5582ms7384 KiB
//#include <fstream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

//ifstream fin("be.in");

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()
{
    cin>>n;
    tav=n;
    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<n/2; ++i)
        mp.push({x[i].jon, i});

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

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

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

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

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base5/55
1Accepted0/03ms1680 KiB
2Wrong answer0/082ms5508 KiB
3Partially correct1/22ms2244 KiB
4Wrong answer0/22ms2340 KiB
5Wrong answer0/22ms2584 KiB
6Wrong answer0/22ms2660 KiB
7Wrong answer0/22ms2628 KiB
8Wrong answer0/32ms2748 KiB
9Wrong answer0/32ms2744 KiB
10Wrong answer0/32ms2876 KiB
11Wrong answer0/36ms3224 KiB
12Wrong answer0/38ms3524 KiB
13Wrong answer0/38ms3596 KiB
14Wrong answer0/316ms4160 KiB
15Wrong answer0/316ms4352 KiB
16Wrong answer0/316ms4352 KiB
17Wrong answer0/316ms4480 KiB
18Wrong answer0/325ms4660 KiB
19Partially correct1/379ms7148 KiB
20Accepted3/371ms7280 KiB
21Wrong answer0/381ms7356 KiB
22Wrong answer0/381ms7384 KiB