12062022-03-20 10:37:24HorakZsofiLeghosszabb béke (75 pont)cpp11Accepted 75/7559ms8424 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
int m,n;
cin>>m>>n;
int szaml=0;
int maxi=0;
int kezd=1;
int kezdmax=0;
vector<int>haboru(m+2);
haboru[m+1]=1;
for(int i=0; i<n; i++){
	int x,y;
	cin>>x>>y;
	haboru[x]++;
	haboru[y+1]--;

}	

for(int i=1; i<m+2; i++){
	haboru[i]+=haboru[i-1];
	if(haboru[i]==0){
		szaml++;
	}
	else{
		if(maxi<szaml){
			maxi=szaml;
			kezdmax=kezd;
		}
		kezd=i+1;
		szaml=0;
	}
}	
if(maxi==0){
	cout<<"-1"; return 0;
}
cout<<maxi<<" "<<kezdmax;
return 0;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/02ms1772 KiB
2Accepted0/059ms3668 KiB
3Accepted3/31ms2984 KiB
4Accepted3/31ms2984 KiB
5Accepted3/31ms2988 KiB
6Accepted3/31ms2992 KiB
7Accepted3/31ms2996 KiB
8Accepted4/41ms3004 KiB
9Accepted4/41ms3028 KiB
10Accepted4/41ms3052 KiB
11Accepted4/44ms3048 KiB
12Accepted4/44ms3272 KiB
13Accepted4/44ms3228 KiB
14Accepted4/44ms3412 KiB
15Accepted4/44ms3468 KiB
16Accepted4/46ms3604 KiB
17Accepted4/46ms3784 KiB
18Accepted4/47ms3876 KiB
19Accepted4/450ms5388 KiB
20Accepted4/450ms6428 KiB
21Accepted4/446ms7320 KiB
22Accepted4/452ms8424 KiB