130342025-01-05 11:23:09ercseferencTalálkozáscpp17Wrong answer 23/5570ms1096 KiB
#include <iostream>
using namespace std;
int a[100001],b[100001];
int main()
{
    int n,x,y,maxi=0; cin>>n;
    for(int i=0; i<n; i++){cin>>x>>y; a[x]++; b[y]++; if(y>maxi)maxi=y;}
    int s=0,kez,veg,l,k=(n+1)/2,tart=100001;
    for(int i=1; i<=maxi; i++){
        if(l<i)l=i;
        while(s<k && l<=maxi){s=s+a[l]; l++;}
        if(l-i<tart && s>=k){tart=l-i; kez=i; veg=l-1;}
        s=s-b[i]; if(tart==1)break;}
    cout<<tart<<endl<<kez<<" "<<veg;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base23/55
1Wrong answer0/01ms500 KiB
2Accepted0/068ms1080 KiB
3Wrong answer0/21ms508 KiB
4Wrong answer0/21ms320 KiB
5Accepted2/21ms320 KiB
6Wrong answer0/21ms320 KiB
7Wrong answer0/21ms320 KiB
8Wrong answer0/31ms320 KiB
9Accepted3/31ms320 KiB
10Wrong answer0/31ms508 KiB
11Wrong answer0/34ms788 KiB
12Accepted3/37ms680 KiB
13Accepted3/38ms568 KiB
14Wrong answer0/313ms568 KiB
15Wrong answer0/313ms664 KiB
16Accepted3/313ms608 KiB
17Wrong answer0/313ms728 KiB
18Accepted3/321ms1080 KiB
19Accepted3/370ms748 KiB
20Wrong answer0/361ms420 KiB
21Accepted3/367ms1096 KiB
22Wrong answer0/367ms1080 KiB