146372025-01-22 19:38:39miszorimarciLeghosszabb béke (75 pont)cpp17Wrong answer 0/7579ms1332 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, M; cin >> N >> M;
	vector<int>T(N+1);
	for(int i = 0; i < M; i++)
	{
		int s, e; cin >> s >> e;
		T[s]++;
		T[e]--;
	}
	for(int i = 1; i <= N; i++)T[i] += T[i-1];
	T[0]++;
	int mx = -1, bg = -1, c = 0, c_bg;
	for(int i = 1; i <= N; i++)
	{
		if(T[i] == 0)
		{
			c++;
			if(T[i-1] != 0)
			{
				c_bg = i;
			}
		}
		else
		{
			if(c > mx)
			{
				mx = c;
				bg = c_bg;
			}
			c = 0;
		}
	}
	if(mx == -1)
	{
		cout << mx;
		return 0;
	}
	mx--;
	bg++;
	for(int i : T)cout << i << " ";
	cout << "\n"; 
	cout << mx << " " << bg;
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/01ms500 KiB
2Wrong answer0/079ms1076 KiB
3Wrong answer0/31ms316 KiB
4Wrong answer0/31ms316 KiB
5Wrong answer0/31ms316 KiB
6Wrong answer0/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/41ms316 KiB
9Wrong answer0/42ms316 KiB
10Wrong answer0/42ms316 KiB
11Wrong answer0/44ms508 KiB
12Wrong answer0/48ms316 KiB
13Wrong answer0/46ms508 KiB
14Wrong answer0/47ms316 KiB
15Wrong answer0/48ms468 KiB
16Wrong answer0/48ms520 KiB
17Wrong answer0/410ms580 KiB
18Wrong answer0/413ms820 KiB
19Wrong answer0/471ms1316 KiB
20Wrong answer0/471ms1332 KiB
21Wrong answer0/470ms1332 KiB
22Wrong answer0/471ms1316 KiB