235972026-01-26 07:59:56pirosmacska10Leghosszabb béke (75 pont)cpp17Time limit exceeded 47/75300ms820 KiB
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <climits>
using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, m;
    cin >> n >> m;
    vector<bool> days(n+1, 0);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        for(int j = a; j <= b; j++) {
            days[j] = 1;
        }
    }

    int maxx = 0;
    int first = -1;
    int run = 0;
    for(int i = 1; i <= n; i++) {
        if(days[i]) {
            run = 0;
        } else {
            run++;
            if(maxx < run) {
                maxx = run;
                first = i-run+1;
            }
        }
    }
    if(first == -1) cout << "-1\n";
    else cout << maxx << " " << first;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base47/75
1Accepted0/01ms316 KiB
2Time limit exceeded0/0284ms820 KiB
3Accepted3/31ms316 KiB
4Accepted3/31ms316 KiB
5Accepted3/31ms316 KiB
6Accepted3/31ms316 KiB
7Accepted3/31ms316 KiB
8Accepted4/41ms316 KiB
9Accepted4/41ms316 KiB
10Accepted4/42ms316 KiB
11Accepted4/417ms420 KiB
12Accepted4/441ms440 KiB
13Accepted4/426ms468 KiB
14Accepted4/429ms316 KiB
15Accepted4/439ms476 KiB
16Time limit exceeded0/4252ms316 KiB
17Time limit exceeded0/4282ms500 KiB
18Time limit exceeded0/4300ms440 KiB
19Time limit exceeded0/4282ms708 KiB
20Time limit exceeded0/4287ms316 KiB
21Time limit exceeded0/4280ms316 KiB
22Time limit exceeded0/4298ms452 KiB