76492024-01-10 10:35:12AblablablaTalálkozáscpp17Wrong answer 0/55125ms5864 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

const int INF = 2e9 + 7;
const int MAXN = 1e5 + 5;

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

    vector<int> jon(MAXN);
    vector<int> megy(MAXN);
    int maxi = 0;
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;

        jon[a]++;
        megy[b]++;

        maxi = max(maxi, b);
    }

    int elso = 0, masodik = 1;
    int benne = jon[1];
    int cel = n / 2 + (n % 2);
    int mini = INF;
    pii megoldas;
    while(elso <= masodik && masodik < maxi){
        cout << elso << " " << masodik << " : " << benne << "\n";
        if(benne >= cel){
            if(mini > masodik - elso + 1){
                mini = masodik - elso + 1;
                megoldas = {elso, masodik};
            }
            benne -= megy[elso];
            elso++;
        } else if(benne < cel){
            masodik++;
            benne += jon[masodik];
        }
    }

    cout << mini << "\n" << megoldas.first << " " << megoldas.second << "\n";
}
SubtaskSumTestVerdictTimeMemory
base0/55
1Wrong answer0/04ms3168 KiB
2Wrong answer0/0122ms3508 KiB
3Wrong answer0/23ms3828 KiB
4Wrong answer0/23ms3820 KiB
5Wrong answer0/23ms4184 KiB
6Wrong answer0/26ms4244 KiB
7Wrong answer0/26ms4588 KiB
8Wrong answer0/36ms4596 KiB
9Wrong answer0/38ms4644 KiB
10Wrong answer0/38ms4628 KiB
11Wrong answer0/334ms4632 KiB
12Wrong answer0/335ms4780 KiB
13Wrong answer0/335ms4876 KiB
14Wrong answer0/341ms4832 KiB
15Wrong answer0/341ms5088 KiB
16Wrong answer0/341ms5388 KiB
17Wrong answer0/341ms5408 KiB
18Wrong answer0/375ms5500 KiB
19Wrong answer0/3104ms5444 KiB
20Wrong answer0/398ms5596 KiB
21Wrong answer0/3125ms5664 KiB
22Wrong answer0/3122ms5864 KiB