67322023-12-18 12:00:01szasztundeTalálkozáscpp17Wrong answer 0/5593ms64860 KiB
#include <bits/stdc++.h>

using namespace std;
 set<int> halmaz[100001];
int main()
{
    unsigned n;
    cin >> n;

    unsigned x, y, _max=0;

    set<int> koz;

    for(unsigned i=1; i<=n; i++) {
        cin >> x >> y;
        for(unsigned k=x; k<=y; k++) {
            halmaz[k].insert(i);
        }
        if(y>_max) {
            _max=y;
        }
    }

    unsigned z, lep, _min=1000, e, t, k, v, vmax, vissza=_max;
    while(z>=1) {
        vmax=0;
        z=vissza;
        v=z;
        lep=0;
        while(koz.size()<n/2 && z>=1) {
            if(halmaz[z].size()>=vmax) {
                vmax=halmaz[z].size();
                vissza=z;
            }
            koz.insert(halmaz[z].begin(), halmaz[z].end());
            z--;
            lep++;
        }
        if(vissza==v) {
            vissza=z+1;
        }
        k=z+1;
        if(lep<_min) {
            _min=lep;
            e=k;
            t=v;
        }
        koz.clear();
    }

    cout << _min << endl << e << " " << t ;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/06ms11236 KiB
2Runtime error0/070ms64860 KiB
3Wrong answer0/26ms11648 KiB
4Wrong answer0/24ms11624 KiB
5Wrong answer0/26ms11880 KiB
6Wrong answer0/27ms12972 KiB
7Wrong answer0/28ms14756 KiB
8Wrong answer0/36ms12440 KiB
9Wrong answer0/36ms12908 KiB
10Wrong answer0/38ms14724 KiB
11Runtime error0/359ms64104 KiB
12Runtime error0/361ms64088 KiB
13Runtime error0/374ms64064 KiB
14Runtime error0/382ms63828 KiB
15Runtime error0/382ms63804 KiB
16Runtime error0/379ms63572 KiB
17Runtime error0/378ms63560 KiB
18Runtime error0/393ms63552 KiB
19Runtime error0/356ms63324 KiB
20Runtime error0/352ms63312 KiB
21Runtime error0/364ms63304 KiB
22Runtime error0/365ms63276 KiB