147932025-02-02 17:51:47sarminLeghosszabb béke (75 pont)cpp17Wrong answer 72/7520ms820 KiB
// Created by Armin on 2/1/2025.

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<int, int>;


int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    int n, m; cin >> n >> m;
    vector<int> prefix(n + 2);
    for (int i = 0; i < m; i++) {
      int a, b; cin >> a >> b;
      prefix[a]++;
      prefix[b + 1]--;
    }
    
    for (int i = 1; i <= n; i++) {
      prefix[i] += prefix[i - 1];
    }
    prefix[0] = 1;
    prefix[n + 1] = 1;
    
    int start = 0, maxstart = 0, maxlength = 0;
    for (int i = 1; i <= n + 1; i++) {
      if (prefix[i] != 0) {
        if (i - start - 1 > maxlength) {
          maxlength = i - start - 1;
          maxstart = start + 1;
        }
        start = i;
      }
    }
    cout << maxlength << " " << maxstart;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base72/75
1Accepted0/01ms316 KiB
2Accepted0/020ms820 KiB
3Wrong answer0/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted4/41ms316 KiB
11Accepted4/42ms500 KiB
12Accepted4/43ms316 KiB
13Accepted4/42ms316 KiB
14Accepted4/42ms500 KiB
15Accepted4/43ms316 KiB
16Accepted4/43ms508 KiB
17Accepted4/43ms564 KiB
18Accepted4/43ms564 KiB
19Accepted4/418ms820 KiB
20Accepted4/419ms820 KiB
21Accepted4/418ms820 KiB
22Accepted4/419ms820 KiB