48762023-04-05 20:31:39CWMLegmesszebbi rossz sorrendű (35 pont)cpp17Elfogadva 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;
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base35/35
1Elfogadva0/03ms2104 KiB
2Elfogadva0/026ms4396 KiB
3Elfogadva1/13ms2552 KiB
4Elfogadva1/13ms2556 KiB
5Elfogadva1/12ms2792 KiB
6Elfogadva1/13ms2796 KiB
7Elfogadva1/13ms3016 KiB
8Elfogadva1/13ms3104 KiB
9Elfogadva1/13ms3384 KiB
10Elfogadva1/13ms3360 KiB
11Elfogadva1/13ms3620 KiB
12Elfogadva2/210ms4728 KiB
13Elfogadva2/212ms4728 KiB
14Elfogadva2/212ms4880 KiB
15Elfogadva2/28ms4432 KiB
16Elfogadva2/213ms4904 KiB
17Elfogadva2/218ms5956 KiB
18Elfogadva2/221ms6120 KiB
19Elfogadva2/223ms6248 KiB
20Elfogadva2/224ms6264 KiB
21Elfogadva2/226ms6168 KiB
22Elfogadva2/226ms6160 KiB
23Elfogadva2/217ms6416 KiB
24Elfogadva2/217ms6368 KiB