149002025-02-06 16:41:21PKBLegcsalódottabb versenyző (75 pont)cpp14Wrong answer 45/7535ms1684 KiB
#include <iostream>
#include <vector>
using namespace std;

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

    vector<int> nextGreater(n, -1);
    vector<int> st;
    for (int i = 0; i < n; i++){
        while (!st.empty() && score[i] > score[st.back()]){
            nextGreater[st.back()] = i;
            st.pop_back();
        }
        st.push_back(i);
    }

    int maxDuration = -1;
    int resultIndex = -1;

    for (int i = 0; i < n; i++){
        if (nextGreater[i] != -1) {
            int duration = nextGreater[i] - i;
            if (duration > maxDuration) {
                maxDuration = duration;
                resultIndex = i;
            }
        }
    }


    if (resultIndex == -1)
        cout << -1;
    else
        cout << resultIndex + 1;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base45/75
1Accepted0/01ms316 KiB
2Wrong answer0/035ms1588 KiB
3Accepted5/51ms316 KiB
4Accepted5/51ms316 KiB
5Accepted5/51ms316 KiB
6Accepted5/51ms512 KiB
7Wrong answer0/51ms508 KiB
8Accepted5/51ms556 KiB
9Accepted5/51ms316 KiB
10Wrong answer0/51ms400 KiB
11Accepted5/51ms316 KiB
12Accepted5/51ms316 KiB
13Accepted5/535ms1684 KiB
14Wrong answer0/535ms1680 KiB
15Wrong answer0/535ms1560 KiB
16Wrong answer0/535ms1532 KiB
17Wrong answer0/535ms1588 KiB