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;
bool s(vector<long long> v, int n){
int c=0;
for(int i=0;i<n;i++){
if(v[i]<=v[i+1]){
c++;
}
}
if(c==n){
return true;
}
return false;
}
int main(){
long long n,x,ci=0,cd=0,cont=0;
cin>>n;
vector<long long> v;
v.reserve(n);
for(int i=0;i<n;i++){
cin>>x;
v.push_back(x);
}
if(s(v,n)){
cout<<"0 \n";
return 0;
}
for(int i=1;i<n-1;i++){
ci=0;cd=0;
for(int j=0;j<i;j++){
if(v[j]<v[i]){
ci++;
}
}
for(int k=i+1;k<n;k++){
if(v[k]<v[i]){
cd++;
}
}
cont+=ci*cd;
}
cout<<cont<<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... |