56302023-08-29 12:57:40TomaSajtLeghosszabb béke (75 pont)cpp17Accepted 75/7525ms11604 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
  cin.tie(0), ios::sync_with_stdio(0);

  int n, m;
  cin >> n >> m;

  vector<int> d(n + 1);
  while (m--) {
    int s, e;
    cin >> s >> e;
    d[s]++, d[e + 1]--;
  }

  vector<int> c(n + 1);
  partial_sum(d.begin(), d.end(), c.begin());

  int len = 0, best_len = 0, best_start;
  for (int i = n; i >= 1; i--) {
    if (c[i] != 0) {
      len = 0;
      continue;
    }
    len++;
    if (len >= best_len) {
      best_len = len;
      best_start = i;
    }
  }

  if (best_len == 0) {
    cout << "-1";
    return 0;
  }
  cout << best_len << ' ' << best_start;
}
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/03ms1824 KiB
2Accepted0/025ms4676 KiB
3Accepted3/32ms3304 KiB
4Accepted3/33ms3424 KiB
5Accepted3/32ms3536 KiB
6Accepted3/33ms3668 KiB
7Accepted3/32ms3756 KiB
8Accepted4/43ms3884 KiB
9Accepted4/42ms3996 KiB
10Accepted4/43ms4336 KiB
11Accepted4/44ms4680 KiB
12Accepted4/44ms4952 KiB
13Accepted4/44ms5056 KiB
14Accepted4/44ms5344 KiB
15Accepted4/44ms5572 KiB
16Accepted4/44ms5652 KiB
17Accepted4/44ms5788 KiB
18Accepted4/44ms6300 KiB
19Accepted4/423ms8040 KiB
20Accepted4/423ms9332 KiB
21Accepted4/421ms10264 KiB
22Accepted4/423ms11604 KiB