42412023-03-17 22:58:28xxxLeghosszabb béke (75 pont)cpp14Time limit exceeded 59/75300ms4516 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    int haboruk[n+1] = {0};
    vector<pair<int, int>> a(m);
    for (int i = 0; i < m; i++) {
        cin >> a[i].first >> a[i].second;
        for (int j = a[i].first; j <= a[i].second; j++) {
            haboruk[j]++;
        }
    }
    bool volte = false;
    int maxos = 0, cnt = 0, ans;
    for(int i = 1; i <= n; i++) {
        if (haboruk[i] == 0) {
            cnt++;
            volte = true;
        }
        else {
            cnt = 0;
        }
        if (cnt > maxos) {
            maxos = cnt;
            ans = i - cnt;
        }
    }
    if (!volte) cout << -1 << endl; else
    cout << maxos << " " << ans + 1 << endl;

}
SubtaskSumTestVerdictTimeMemory
base59/75
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0300ms2408 KiB
3Accepted3/33ms2264 KiB
4Accepted3/33ms2424 KiB
5Accepted3/33ms2636 KiB
6Accepted3/32ms2756 KiB
7Accepted3/33ms2984 KiB
8Accepted4/43ms3088 KiB
9Accepted4/43ms3036 KiB
10Accepted4/43ms3308 KiB
11Accepted4/48ms3428 KiB
12Accepted4/416ms3580 KiB
13Accepted4/410ms3436 KiB
14Accepted4/413ms3688 KiB
15Accepted4/416ms3796 KiB
16Accepted4/467ms3840 KiB
17Accepted4/489ms4036 KiB
18Accepted4/4153ms4120 KiB
19Time limit exceeded0/4266ms4516 KiB
20Time limit exceeded0/4221ms4340 KiB
21Time limit exceeded0/4280ms4212 KiB
22Time limit exceeded0/4284ms4272 KiB