#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);
ull 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);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
2084 ms |
2688 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2092 ms |
2688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2092 ms |
2688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
5 ms |
384 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
384 KB |
Output is correct |
11 |
Correct |
57 ms |
384 KB |
Output is correct |
12 |
Correct |
57 ms |
384 KB |
Output is correct |
13 |
Correct |
56 ms |
384 KB |
Output is correct |
14 |
Correct |
59 ms |
504 KB |
Output is correct |
15 |
Correct |
57 ms |
384 KB |
Output is correct |
16 |
Correct |
57 ms |
384 KB |
Output is correct |
17 |
Correct |
57 ms |
504 KB |
Output is correct |
18 |
Correct |
58 ms |
384 KB |
Output is correct |
19 |
Correct |
64 ms |
384 KB |
Output is correct |
20 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2092 ms |
2688 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Execution timed out |
2084 ms |
2688 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |