201432026-01-03 09:20:42szjTalálkozáspython3Runtime error 0/5516ms3136 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
base0/55
1Runtime error0/016ms2872 KiB
2Runtime error0/016ms2860 KiB
3Runtime error0/216ms2864 KiB
4Runtime error0/216ms2868 KiB
5Runtime error0/216ms2872 KiB
6Runtime error0/216ms3136 KiB
7Runtime error0/214ms3008 KiB
8Runtime error0/314ms2868 KiB
9Runtime error0/316ms2868 KiB
10Runtime error0/314ms2868 KiB
11Runtime error0/316ms2884 KiB
12Runtime error0/314ms2868 KiB
13Runtime error0/316ms2988 KiB
14Runtime error0/316ms2988 KiB
15Runtime error0/316ms3028 KiB
16Runtime error0/316ms3040 KiB
17Runtime error0/314ms3044 KiB
18Runtime error0/316ms2868 KiB
19Runtime error0/314ms3052 KiB
20Runtime error0/316ms2916 KiB
21Runtime error0/316ms3004 KiB
22Runtime error0/314ms2856 KiB