135222025-01-08 09:22:17feheristvanTalálkozáscpp17Wrong answer 0/5567ms1268 KiB
#include <iostream>
#include <vector>

using namespace std;

int main()
{
    int n;
    int megy[100001] = {0};
    int jon[100001] = {0};
    int x, y, maxx = 0;
    cin >> n;
    for(int i = 1; i <= n ; i ++){
        cin >> x >> y;
        jon[x] ++;
        megy[y] ++;
        if (y > maxx)
            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/02ms1268 KiB
2Wrong answer0/064ms1076 KiB
3Wrong answer0/22ms1076 KiB
4Wrong answer0/22ms1076 KiB
5Wrong answer0/21ms1076 KiB
6Wrong answer0/22ms1076 KiB
7Wrong answer0/22ms1076 KiB
8Wrong answer0/32ms1076 KiB
9Wrong answer0/32ms1076 KiB
10Wrong answer0/32ms1268 KiB
11Wrong answer0/36ms1260 KiB
12Wrong answer0/37ms1180 KiB
13Wrong answer0/38ms1184 KiB
14Wrong answer0/313ms1176 KiB
15Wrong answer0/313ms1172 KiB
16Wrong answer0/313ms1176 KiB
17Wrong answer0/313ms1180 KiB
18Wrong answer0/320ms1176 KiB
19Wrong answer0/367ms1176 KiB
20Wrong answer0/359ms1176 KiB
21Wrong answer0/364ms1180 KiB
22Wrong answer0/364ms1172 KiB