48762023-04-05 20:31:39CWMLegmesszebbi rossz sorrendű (35 pont)cpp17Accepted 35/3526ms6416 KiB
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <unordered_set>

//upper bound >
//lower bound >=
//int index = (lower_bound(testvec.begin(), testvec.end(), num)-testvec.begin());

using namespace std;
using ll = long long;
int mod = 1000000007;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n;
    cin >> n;
    vector<pair<int, int>> val; //val index
    for (size_t i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        val.push_back({ a,i });
    }
    sort(val.begin(), val.end());
    int maxIx = val[0].second;
    int HighestIndexNumberIndex = 0;
    int maxDist = -1;
    int index1 = -1;
    int index2 = -1;
    for (size_t i = 1; i < val.size(); i++)
    {
        if (maxIx < val[i].second) {
            maxIx = val[i].second;
            HighestIndexNumberIndex = i;
        }
        else if (maxDist < (maxIx - val[i].second)) {
            maxDist = maxIx - val[i].second;
            index1 = HighestIndexNumberIndex;
            index2 = i;
        }
    }
    if (index1 == -1) {
        cout << "-1";
        return 0;
    }
    if (val[index1].second > val[index2].second) {
        int temp = index1;
        index1 = index2;
        index2 = temp;
    }
    cout << val[index1].second+1 << " " << val[index2].second+1;
}
SubtaskSumTestVerdictTimeMemory
base35/35
1Accepted0/03ms2104 KiB
2Accepted0/026ms4396 KiB
3Accepted1/13ms2552 KiB
4Accepted1/13ms2556 KiB
5Accepted1/12ms2792 KiB
6Accepted1/13ms2796 KiB
7Accepted1/13ms3016 KiB
8Accepted1/13ms3104 KiB
9Accepted1/13ms3384 KiB
10Accepted1/13ms3360 KiB
11Accepted1/13ms3620 KiB
12Accepted2/210ms4728 KiB
13Accepted2/212ms4728 KiB
14Accepted2/212ms4880 KiB
15Accepted2/28ms4432 KiB
16Accepted2/213ms4904 KiB
17Accepted2/218ms5956 KiB
18Accepted2/221ms6120 KiB
19Accepted2/223ms6248 KiB
20Accepted2/224ms6264 KiB
21Accepted2/226ms6168 KiB
22Accepted2/226ms6160 KiB
23Accepted2/217ms6416 KiB
24Accepted2/217ms6368 KiB