70992023-12-30 12:15:52MagyarKendeSZLGLeghosszabb béke (75 pont)cpp17Wrong answer 42/7564ms6964 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 (result[0] < e - pos) {
            result[0] = e - pos;
            result[1] = pos;
        }
        pos = max(pos, v + 1);
    }

    cout << result[0] + 1 << ' ' << result[1];
}
SubtaskSumTestVerdictTimeMemory
base42/75
1Wrong answer0/03ms1828 KiB
2Accepted0/064ms5572 KiB
3Wrong answer0/33ms2272 KiB
4Wrong answer0/33ms2352 KiB
5Accepted3/33ms2580 KiB
6Wrong answer0/33ms2832 KiB
7Accepted3/33ms2880 KiB
8Accepted4/43ms2792 KiB
9Accepted4/43ms2920 KiB
10Accepted4/43ms3020 KiB
11Accepted4/46ms3532 KiB
12Accepted4/47ms3916 KiB
13Accepted4/44ms4068 KiB
14Accepted4/46ms4040 KiB
15Accepted4/47ms4004 KiB
16Wrong answer0/46ms3684 KiB
17Wrong answer0/46ms3712 KiB
18Wrong answer0/44ms3828 KiB
19Accepted4/459ms6964 KiB
20Wrong answer0/441ms3788 KiB
21Wrong answer0/428ms3880 KiB
22Wrong answer0/441ms4188 KiB