ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1931. Excellent Team

ac
Posted by Knownasgod 12 May 2023 16:08
# include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define vec vector
#define int long long
#define ld long double

#define f first
#define s second

#define pb push_back

#define fe(x, a) for (auto& x : a)

#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using pii = pair<int, int>;

const int mod = 1e9 + 7;
const ll OO = 1e16;
const int N = 1e5 + 2;
const ld eps = 1e-3;

template<typename T>
bool umn(T &a, T b) { return a > b ? (a = b, 1) : 0; }

template<typename T>
bool umx(T &a, T b) { return a < b ? (a = b, 1) : 0; }

void solve() {
    int n, best = -1, ans = 0;
    cin >> n;
    set<pii> setik;
    for (int i = 0, x; i < n + 1; ++i) {
        x = -OO;
        if (i < n)
            cin >> x;
        if (i && x < (*setik.begin()).f)
            if (umx(best, i - (*setik.begin()).s - !(*setik.begin()).s))
                ans = (*setik.begin()).s;

        setik.insert({x, i});
    }
    cout << ans + 1;
}

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

    int t = 1;
//    cin >> t;
    while (t--)
        solve();
}