147922025-02-02 17:50:43sarminLeghosszabb béke (75 pont)cpp17Wrong answer 30/7520ms1004 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; 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
base30/75
1Accepted0/01ms316 KiB
2Wrong answer0/020ms820 KiB
3Wrong answer0/31ms316 KiB
4Accepted3/31ms316 KiB
5Wrong answer0/31ms316 KiB
6Accepted3/31ms316 KiB
7Wrong answer0/31ms316 KiB
8Wrong answer0/41ms316 KiB
9Wrong answer0/41ms500 KiB
10Wrong answer0/41ms316 KiB
11Wrong answer0/42ms356 KiB
12Wrong answer0/43ms316 KiB
13Wrong answer0/42ms508 KiB
14Wrong answer0/42ms316 KiB
15Wrong answer0/42ms316 KiB
16Accepted4/43ms540 KiB
17Accepted4/43ms580 KiB
18Accepted4/43ms564 KiB
19Wrong answer0/418ms1004 KiB
20Accepted4/419ms820 KiB
21Accepted4/419ms820 KiB
22Accepted4/419ms568 KiB