70972023-12-30 11:55:52MagyarKendeSZLGLeghosszabb béke (75 pont)cpp17Wrong answer 0/7564ms9772 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] << '\n' << result[1];
}
SubtaskSumTestVerdictTimeMemory
base0/75
1Wrong answer0/03ms1832 KiB
2Wrong answer0/064ms6708 KiB
3Wrong answer0/33ms3404 KiB
4Wrong answer0/33ms3376 KiB
5Wrong answer0/33ms3512 KiB
6Wrong answer0/33ms3724 KiB
7Wrong answer0/33ms3940 KiB
8Wrong answer0/43ms4032 KiB
9Wrong answer0/43ms4264 KiB
10Wrong answer0/43ms4356 KiB
11Wrong answer0/46ms4880 KiB
12Wrong answer0/47ms5124 KiB
13Wrong answer0/44ms4944 KiB
14Wrong answer0/46ms5140 KiB
15Wrong answer0/47ms5256 KiB
16Wrong answer0/46ms5164 KiB
17Wrong answer0/46ms5508 KiB
18Wrong answer0/44ms5436 KiB
19Wrong answer0/459ms9772 KiB
20Wrong answer0/443ms7552 KiB
21Wrong answer0/428ms8356 KiB
22Wrong answer0/443ms9664 KiB