67332023-12-18 12:03:23szasztundeTalálkozáscpp17Wrong answer 0/5593ms64844 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;
    cout << e << " " << t ;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/07ms11252 KiB
2Runtime error0/070ms64844 KiB
3Wrong answer0/26ms11664 KiB
4Wrong answer0/26ms11632 KiB
5Wrong answer0/26ms11764 KiB
6Wrong answer0/28ms13056 KiB
7Wrong answer0/29ms15216 KiB
8Wrong answer0/37ms12680 KiB
9Wrong answer0/38ms13408 KiB
10Wrong answer0/39ms15436 KiB
11Runtime error0/361ms63944 KiB
12Runtime error0/370ms63708 KiB
13Runtime error0/371ms63564 KiB
14Runtime error0/379ms63324 KiB
15Runtime error0/381ms63244 KiB
16Runtime error0/379ms63232 KiB
17Runtime error0/379ms63188 KiB
18Runtime error0/393ms63204 KiB
19Runtime error0/350ms63064 KiB
20Runtime error0/352ms62828 KiB
21Runtime error0/368ms62796 KiB
22Runtime error0/368ms62788 KiB