201442026-01-03 09:21:00szjTalálkozáscpp17Accepted 55/5572ms784 KiB
#include <bits/stdc++.h>

using namespace std;
class has
{
 public:
     bool operator()(int a, int b)
     {
         return a>b;
     }
};
int main()
{
    int n, i, mi=100001, a, b, c, d;
    cin >> n;
    int n2=ceil(n/2.0);
    priority_queue<int, vector<int>, has> q;
    for(i=0; i<n; i++)
    {
        cin >> c >> d;
        q.push(d);
        while(q.size()>n2)q.pop();
        if(mi>c-q.top()  && q.size()>=n2)
        {
            if(c-q.top()>=0)
            {
                mi=c-q.top();
                a=q.top();
                b=c;
            }
            else
            {
                cout  << 1 << endl <<c << ' ' << c;
                return 0;
            }
        }
    }
    cout << mi+1 << endl;
    cout << a << " " << b;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base55/55
1Accepted0/01ms316 KiB
2Accepted0/072ms688 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/34ms560 KiB
12Accepted3/38ms316 KiB
13Accepted3/37ms316 KiB
14Accepted3/313ms316 KiB
15Accepted3/314ms592 KiB
16Accepted3/313ms500 KiB
17Accepted3/313ms316 KiB
18Accepted3/321ms520 KiB
19Accepted3/337ms784 KiB
20Accepted3/364ms688 KiB
21Accepted3/372ms772 KiB
22Accepted3/372ms628 KiB