87522024-01-28 17:44:30IgnácLeghosszabb béke (75 pont)cpp17Wrong answer 33/7578ms4844 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> war(m);
	for (int i = 0; i < m; i++) {
		cin >> war[i].first >> war[i].second;
	}

	sort(war.begin(), war.end());
	int end = 0, maxh = 0, maxk = 0;
	for (int i = 0; i < m; i++) {
		if (war[i].first > end + 1) {
			if (war[i].first - end - 1 > maxh) {
				maxh = war[i].first - end - 1;
				maxk = end + 1;
			}
		}

		if (war[i].second > end) end = war[i].second;
	}

	if (maxh == 0) cout << -1;
	else cout << maxh << " " << maxk; 
}
SubtaskSumTestVerdictTimeMemory
base33/75
1Accepted0/03ms1812 KiB
2Wrong answer0/078ms3360 KiB
3Accepted3/33ms2220 KiB
4Accepted3/33ms2448 KiB
5Wrong answer0/32ms2624 KiB
6Accepted3/32ms2552 KiB
7Wrong answer0/33ms2772 KiB
8Wrong answer0/43ms2964 KiB
9Wrong answer0/42ms3044 KiB
10Wrong answer0/43ms3212 KiB
11Wrong answer0/46ms3244 KiB
12Wrong answer0/48ms3408 KiB
13Wrong answer0/46ms3440 KiB
14Wrong answer0/47ms3600 KiB
15Wrong answer0/48ms3528 KiB
16Accepted4/48ms3592 KiB
17Accepted4/48ms3536 KiB
18Accepted4/48ms3544 KiB
19Wrong answer0/471ms4696 KiB
20Accepted4/472ms4700 KiB
21Accepted4/470ms4844 KiB
22Accepted4/472ms4700 KiB