# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
232940 | kristopher23 | Mountains (NOI20_mountains) | C++17 | 2087 ms | 4608 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;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr auto MOD = 1e9 + 7;
constexpr auto INF = 0x3f3f3f3f;
#define rep(i, a, b) for (auto i = a; i < b; ++i)
template <class T> inline T square(T x) { return x * x; };
template <class T> void print(const T &val) { cout << val << '\n'; }
template <class Iterator> void print(Iterator begin, Iterator end) {
for (auto it = begin; it != end; ++it) {
cout << *it << ' ';
}
cout << '\n';
}
using ull = unsigned long long;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n;
cin >> n;
vector<ull> a(n);
for (auto &i : a) {
cin >> i;
}
ull ans = 0;
for (ull i = 1; i < n - 1; ++i) {
ull x = 0, y = 0;
for (ull j = 0; j < i; ++j) {
if (a[j] < a[i]) {
++x;
}
}
for (ull j = i + 1; j < n; ++j) {
if (a[j] < a[i]) {
++y;
}
}
ans += (x * y);
}
print(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... |