135132025-01-08 09:13:03feheristvanTalálkozáscpp17Wrong answer 0/5568ms1268 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    int megy[100000] = {0};
    int jon[100000] = {0};
    int x, y, maxx = 0;
    cin >> n;
    for(int i = 0; i < n ; i ++){
        cin >> x >> y;
        jon[x] ++;
        megy[y] ++;
    }
    maxx = y;
    int lx, ly, j = 0, ossz, db = 100001;
    bool t = 1;
    for(int i = 1 ; i <= maxx; i ++){
        while(j < maxx and ossz < (n + 1) / 2){
            j ++;
            ossz += jon[j];
        }
        if(j == maxx and ossz < (n + 1) / 2){
            t = 0;
        }
        if(j - i + 1 < db and ossz >= (n + 1) / 2 and t and j - i + 1 > 0){
            db = j - i + 1;
            ly = j;
            lx = i;
        }
        ossz -= megy[i];
    }
    cout << db << endl;
    cout <<lx << " " << ly;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/01ms1076 KiB
2Wrong answer0/064ms1076 KiB
3Wrong answer0/22ms1076 KiB
4Wrong answer0/22ms1076 KiB
5Wrong answer0/22ms1148 KiB
6Wrong answer0/22ms1112 KiB
7Wrong answer0/22ms1076 KiB
8Wrong answer0/32ms1268 KiB
9Wrong answer0/32ms1076 KiB
10Wrong answer0/32ms1076 KiB
11Wrong answer0/34ms1076 KiB
12Wrong answer0/37ms1076 KiB
13Wrong answer0/37ms1180 KiB
14Wrong answer0/313ms1180 KiB
15Wrong answer0/313ms1172 KiB
16Wrong answer0/313ms1076 KiB
17Wrong answer0/313ms1176 KiB
18Wrong answer0/320ms1160 KiB
19Wrong answer0/368ms1176 KiB
20Wrong answer0/359ms1188 KiB
21Wrong answer0/364ms1176 KiB
22Wrong answer0/364ms1076 KiB