70982023-12-30 11:57:32MagyarKendeSZLGLeghosszabb béke (75 pont)cpp17Wrong answer 27/7564ms6676 KiB
#include <bits/stdc++.h>

#define speed cin.tie(0); ios::sync_with_stdio(0)
#define cinv(v) for (auto& e : v) cin >> e;
#define all(v) v.begin(), v.end()
#define has(s, e) s.count(e)

using namespace std;
using ll = long long;
using point = array<int, 2>;

int main() {
    speed;

    int N, M;
    cin >> N >> M;
    map<int, int> from;
    while (M--) {
        int a, b;
        cin >> a >> b;
        from[a] = max(from[a], b);
    }
    from[N] = N;

    point result = {0, 0};
    int pos = 1;

    for (auto [e, v] : from) {
        if (pos == N) break;
        if (pos < e) {
            if (result[0] < e - pos - 1) {
                result[0] = e - pos - 1;
                result[1] = pos + 1;
            }
        }
        pos = max(pos, v);
    }

    cout << result[0] << ' ' << result[1];
}
SubtaskSumTestVerdictTimeMemory
base27/75
1Accepted0/03ms1832 KiB
2Wrong answer0/064ms5568 KiB
3Wrong answer0/32ms2136 KiB
4Wrong answer0/33ms2336 KiB
5Wrong answer0/32ms2324 KiB
6Accepted3/33ms2548 KiB
7Wrong answer0/33ms2656 KiB
8Wrong answer0/43ms2628 KiB
9Wrong answer0/43ms2636 KiB
10Wrong answer0/43ms2660 KiB
11Wrong answer0/44ms2904 KiB
12Wrong answer0/47ms3120 KiB
13Wrong answer0/44ms3312 KiB
14Wrong answer0/46ms3424 KiB
15Wrong answer0/47ms3412 KiB
16Accepted4/44ms3088 KiB
17Accepted4/46ms3372 KiB
18Accepted4/44ms3196 KiB
19Wrong answer0/459ms6676 KiB
20Accepted4/443ms3628 KiB
21Accepted4/428ms3552 KiB
22Accepted4/443ms3840 KiB