187272025-11-01 11:21:20PKBLapozgatáscpp17Time limit exceeded 24/100612ms225848 KiB
#include <bits/stdc++.h>
using namespace std;

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

    long long M, K;
    int N;
    cin >> M >> K >> N;

    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    unordered_set<long long> latta;
    latta.insert(K);

    long long curr = K;
    long long totalFlips = 0;
    int flipStarts = 0;

    for (long long target : A) {
        if (latta.count(target)) continue; // már látta

        flipStarts++;
        totalFlips += llabs(curr - target);

        long long start = min(curr, target);
        long long end = max(curr, target);
        // minden köztes látottn
        for (long long i = start; i <= end; ++i) latta.insert(i);

        curr = target;
    }

    cout << flipStarts << " " << totalFlips << "\n";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Accepted1ms316 KiB
subtask20/12
3Time limit exceeded612ms207728 KiB
4Time limit exceeded611ms225848 KiB
5Time limit exceeded611ms207960 KiB
subtask324/24
6Accepted1ms560 KiB
7Accepted1ms316 KiB
8Accepted4ms316 KiB
9Accepted4ms508 KiB
10Accepted3ms316 KiB
11Accepted2ms316 KiB
subtask40/28
12Time limit exceeded612ms217784 KiB
13Time limit exceeded611ms200024 KiB
14Time limit exceeded611ms200132 KiB
15Time limit exceeded611ms218048 KiB
16Time limit exceeded588ms209080 KiB
17Time limit exceeded588ms209232 KiB
18Time limit exceeded588ms192696 KiB
subtask50/36
19Time limit exceeded586ms46548 KiB
20Time limit exceeded587ms81628 KiB
21Time limit exceeded586ms47804 KiB
22Time limit exceeded586ms43468 KiB
23Time limit exceeded591ms81524 KiB
24Time limit exceeded592ms91792 KiB
25Time limit exceeded597ms177248 KiB
26Time limit exceeded598ms187784 KiB
27Time limit exceeded587ms194744 KiB