50742023-04-14 18:28:54sangerafLeghosszabb béke (75 pont)cpp17Wrong answer 72/7565ms4836 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m; cin >> n >> m;
    vector<int>px(n+1, 0);
    for(int i=0; i<m; i++){
        int a, b; cin >> a >> b;
        px[a]++;
        px[b+1]--;
    }
    int sum=0, hossz=0, maxi=0, ans=-1;
    for(int i=1; i<=n; i++){
        sum+=px[i];
        if(sum==0){
            hossz++;
            if(hossz>maxi){
                maxi=hossz;
                ans=i;
            }
        }else{
            hossz=0;
        }
    }
    cout << maxi << " " << ans-maxi+1 << endl;
}
SubtaskSumTestVerdictTimeMemory
base72/75
1Accepted0/03ms1816 KiB
2Accepted0/065ms2708 KiB
3Wrong answer0/32ms2116 KiB
4Accepted3/32ms2464 KiB
5Accepted3/32ms2404 KiB
6Accepted3/32ms2596 KiB
7Accepted3/32ms2688 KiB
8Accepted4/42ms2680 KiB
9Accepted4/42ms2708 KiB
10Accepted4/43ms2944 KiB
11Accepted4/46ms3032 KiB
12Accepted4/47ms3328 KiB
13Accepted4/44ms3372 KiB
14Accepted4/46ms3368 KiB
15Accepted4/47ms3476 KiB
16Accepted4/47ms3612 KiB
17Accepted4/48ms3808 KiB
18Accepted4/48ms4176 KiB
19Accepted4/459ms4704 KiB
20Accepted4/459ms4584 KiB
21Accepted4/457ms4796 KiB
22Accepted4/459ms4836 KiB