67292023-12-18 11:53:08szasztundeTalálkozáscpp17Wrong answer 0/55108ms64864 KiB
#include <iostream>
#include <set>

using namespace std;

int main()
{
    unsigned n;
    cin >> n;

    unsigned x, y, _max=0;
    set<int> halmaz[10001];
    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 << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/03ms2788 KiB
2Runtime error0/083ms64864 KiB
3Wrong answer0/23ms3200 KiB
4Wrong answer0/23ms3300 KiB
5Wrong answer0/23ms3652 KiB
6Wrong answer0/24ms4752 KiB
7Wrong answer0/26ms6792 KiB
8Wrong answer0/34ms4824 KiB
9Wrong answer0/34ms5372 KiB
10Runtime error0/36ms7372 KiB
11Runtime error0/328ms30788 KiB
12Runtime error0/346ms46328 KiB
13Runtime error0/379ms63164 KiB
14Runtime error0/389ms63036 KiB
15Runtime error0/390ms63032 KiB
16Runtime error0/386ms63052 KiB
17Runtime error0/387ms62816 KiB
18Runtime error0/3108ms62652 KiB
19Runtime error0/34ms6364 KiB
20Runtime error0/34ms6520 KiB
21Runtime error0/371ms62276 KiB
22Runtime error0/359ms54744 KiB