#include <iostream>
#include <vector>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
vector<long long> H(n);
for (int i = 0; i < n; i++) {
cin >> H[i];
}
long long top = 0;
// 1'den n-2'ye y değerleri
for (int y = 1; y < n - 1; y++) {
long long sol = 0; // L
// y'nin solundakiler
for (int x = 0; x < y; x++) {
if (H[x] < H[y]) {
sol++;
}
}
long long sag = 0; // R
// y'nin sağındakiler
for (int z = y + 1; z < n; z++) {
if (H[z] < H[y]) {
sag++;
}
}
top += sol * sag;
}
cout << top << endl;
return 0;
}
# | 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... |