149472025-02-09 12:44:56PKBRendező robot (80 pont)cpp17Wrong answer 0/80120ms10688 KiB
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> arr(N);
    for (int i = 0; i < N; ++i) {
        cin >> arr[i];
    }

    unordered_map<int, int> pos;
    for (int i = 0; i < N; ++i) {
        pos[arr[i]] = i;
    }

    int max_sorted_len = 0;
    int current = 1;

    while (current <= N && pos[current] > pos[current - 1]) {
        max_sorted_len++;
        current++;
    }

    cout << N - max_sorted_len << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/80
1Wrong answer0/01ms316 KiB
2Wrong answer0/01ms512 KiB
3Wrong answer0/21ms316 KiB
4Wrong answer0/31ms316 KiB
5Wrong answer0/31ms360 KiB
6Wrong answer0/22ms316 KiB
7Wrong answer0/22ms316 KiB
8Wrong answer0/22ms404 KiB
9Wrong answer0/22ms500 KiB
10Wrong answer0/22ms404 KiB
11Wrong answer0/22ms316 KiB
12Wrong answer0/22ms408 KiB
13Wrong answer0/22ms316 KiB
14Wrong answer0/22ms316 KiB
15Wrong answer0/22ms316 KiB
16Wrong answer0/22ms508 KiB
17Wrong answer0/22ms508 KiB
18Wrong answer0/4120ms10524 KiB
19Wrong answer0/4120ms10528 KiB
20Wrong answer0/4107ms10460 KiB
21Wrong answer0/4101ms10536 KiB
22Wrong answer0/4101ms10664 KiB
23Wrong answer0/4103ms10664 KiB
24Wrong answer0/4115ms10524 KiB
25Wrong answer0/4112ms10524 KiB
26Wrong answer0/4101ms10664 KiB
27Wrong answer0/4116ms10688 KiB
28Wrong answer0/4103ms10532 KiB
29Wrong answer0/4104ms10524 KiB