135112025-01-08 09:06:40feheristvanTalálkozáscpp17Wrong answer 0/5575ms1260 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 = 0, ly = 100001, j = 0, ossz;
    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 < ly - lx + 1 and ossz >= (n + 1) / 2 and t){
            ly = j;
            lx = i;
        }
        ossz -= megy[i];
    }
    cout << ly - lx + 1 << endl;
    cout <<lx << " " << ly;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/02ms1076 KiB
2Wrong answer0/067ms1076 KiB
3Wrong answer0/21ms1080 KiB
4Wrong answer0/22ms1260 KiB
5Wrong answer0/21ms1076 KiB
6Wrong answer0/22ms1076 KiB
7Wrong answer0/22ms1076 KiB
8Wrong answer0/32ms1076 KiB
9Wrong answer0/31ms1076 KiB
10Wrong answer0/32ms1180 KiB
11Wrong answer0/34ms1076 KiB
12Wrong answer0/38ms1260 KiB
13Wrong answer0/38ms1076 KiB
14Wrong answer0/313ms1180 KiB
15Wrong answer0/314ms1176 KiB
16Wrong answer0/313ms1176 KiB
17Wrong answer0/313ms1076 KiB
18Wrong answer0/320ms1180 KiB
19Wrong answer0/375ms1176 KiB
20Wrong answer0/363ms1172 KiB
21Wrong answer0/367ms1176 KiB
22Wrong answer0/365ms1076 KiB