#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fr first
#define sc second
int INTMAX=1e9+7;
#define endl '\n'
void code(){
}
void contest() {
int n;cin>>n;
vector<int>height(n);
int sum=0;
pair<int,int>kac={0,0};
for(int i=0;i<n;i++){
cin>>height[i];
}
for(int p1=1;p1<n-1;p1++){
for(int i=0,j=p1+1;i<p1||j<n;j++,i++){
if(height[i]<height[p1]&&i<p1){
kac.fr++;
}
if(height[j]<height[p1]&&j<n){
kac.sc++;
}
}
sum+=kac.fr*kac.sc;
kac.fr=0;kac.sc=0;
}
cout<<sum<<endl;
}
int main(){
ios::sync_with_stdio(0);cin.tie(nullptr);
//int t;cin>>t;while(t--)
{
contest();
}
//code();
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... |