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 <iostream>
#include <cmath>
#include <stdio.h>
#include <array>
#include <vector>
#include <list>
#include <algorithm>
#include <utility>
#include <string>
#include <sstream>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#define pp pair<int,int>
#define pll pair<ll, ll>
#define ll long long
using namespace std;
int main() {
//freopen(".in", "r", stdin);
//freopen(".out", "w", stdout);
ll n;
cin >> n;
ll mountains[n];
for (int i = 0; i < n; i++) {
cin >> mountains[i];
}
ll answer = 0;
for (int i = 1; i < n-1; i++) {
ll counter = 0;
for (int j = 0; j < i; j++) {
if (mountains[j] < mountains[i]) {
counter++;
}
}
ll counter1 = 0;
for (int k = i+1; k < n; k++) {
if (mountains[k] < mountains[i]) {
counter1++;
}
}
answer += (counter1)*counter;
}
cout << answer << endl;
}
# | 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... |