# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
438996 | Hausdorf | Mountains (NOI20_mountains) | C++17 | 2098 ms | 10436 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define itn int
#define fi first
#define se second
#pragma optimizatiob ("O3")
#pragma GCC target ("avx2")
#pragma optimization ("unroll_loops")
signed main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; cin >> n;
vector<ll> h(n + 2);
for (int i = 1; i <= n; ++i)
cin >> h[i];
h[0] = h[n + 1] = -2e9;
vector<int> lessleft(n + 2, 0), lessright(n + 2, 0);
//lessleft[0] = -1; lessright[n + 1] = -1;
lessleft[1] = lessright[n] = 0;
for (int i = 2; i <= n; ++i) {
for (int j = 1; j < i; ++j) {
if (h[j] < h[i])
++lessleft[i];
}
}
for (int i = n - 1; i >= 1; --i) {
for (int j = n; j > i; --j) {
if (h[j] < h[i])
++lessright[i];
}
}
ll ans = 0;
for (int i = 1; i <= n; ++i)
ans += 1ll * lessleft[i] * lessright[i];
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |