205962026-01-07 18:42:33PappMatyasKéséscpp17Accepted 50/50146ms2612 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    vector<int> b = a;
    sort(b.begin(), b.end());

    b.erase(unique(b.begin(), b.end()), b.end());
    int k = b.size();

    vector<int> last(k, -1);

    for (int i = n - 1; i >= 0; i--) 
    {
        int idx = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
        if (last[idx] == -1)
        {
            last[idx] = i + 1;
        }
    }

    int answer = n;
    for (int x : last)
    {
        answer = min(answer, x);
    }

    cout << answer;
}


SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms316 KiB
2Accepted0/010ms564 KiB
3Accepted5/52ms508 KiB
4Accepted5/52ms316 KiB
5Accepted5/578ms1964 KiB
6Accepted5/579ms1808 KiB
7Accepted4/4123ms2476 KiB
8Accepted4/4123ms2356 KiB
9Accepted4/4123ms2356 KiB
10Accepted4/4122ms2224 KiB
11Accepted4/4119ms2224 KiB
12Accepted2/2143ms2216 KiB
13Accepted2/2145ms2612 KiB
14Accepted1/1145ms2476 KiB
15Accepted1/1145ms2472 KiB
16Accepted1/1146ms2356 KiB
17Accepted1/1142ms2352 KiB
18Accepted1/1131ms1844 KiB
19Accepted1/1128ms1956 KiB