50732023-04-14 18:27:50sangerafLeghosszabb béke (75 pont)cpp17Wrong answer 0/7565ms10724 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 << endl << ans-maxi+1 << endl;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/03ms1808 KiB
2Wrong answer0/065ms3712 KiB
3Wrong answer0/33ms3216 KiB
4Wrong answer0/32ms3304 KiB
5Wrong answer0/33ms3432 KiB
6Wrong answer0/32ms3524 KiB
7Wrong answer0/33ms3772 KiB
8Wrong answer0/43ms3856 KiB
9Wrong answer0/43ms4012 KiB
10Wrong answer0/43ms4364 KiB
11Wrong answer0/46ms4480 KiB
12Wrong answer0/47ms4716 KiB
13Wrong answer0/46ms4800 KiB
14Wrong answer0/46ms4948 KiB
15Wrong answer0/47ms5104 KiB
16Wrong answer0/48ms5588 KiB
17Wrong answer0/48ms5924 KiB
18Wrong answer0/48ms6044 KiB
19Wrong answer0/459ms7456 KiB
20Wrong answer0/461ms8624 KiB
21Wrong answer0/457ms9608 KiB
22Wrong answer0/461ms10724 KiB