|
|
back to boardac # 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(); } |
|
|