#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
ll n;
cin>>n;
vector<ll> v(n);
int max=-1;
bool ban=true;
for(ll i=0; i<n; i++){
cin>>v[i];
if(v[i]>=max){
max=v[i];
}else{
ban=false;
}
}
if(ban==true){
cout<<"0"<<endl;
return 0;
}
ll cont=1;
ll ans=0;
ll a,b;
while(cont<n-1){
a=0;
b=0;
for(ll i=0; i<cont; i++){
if(v[i]<v[cont]) a++;
}
for(ll i=cont+1; i<n; i++){
if(v[i]<v[cont]) b++;
}
ans+=a*b;
cont++;
}
cout<<ans<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
199 ms |
2644 KB |
Output is correct |
3 |
Correct |
192 ms |
2644 KB |
Output is correct |
4 |
Correct |
179 ms |
2644 KB |
Output is correct |
5 |
Correct |
183 ms |
2644 KB |
Output is correct |
6 |
Correct |
197 ms |
2644 KB |
Output is correct |
7 |
Correct |
180 ms |
2644 KB |
Output is correct |
8 |
Correct |
201 ms |
2644 KB |
Output is correct |
9 |
Correct |
185 ms |
2644 KB |
Output is correct |
10 |
Correct |
185 ms |
2644 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2067 ms |
2644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2067 ms |
2644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2067 ms |
2644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
199 ms |
2644 KB |
Output is correct |
3 |
Correct |
192 ms |
2644 KB |
Output is correct |
4 |
Correct |
179 ms |
2644 KB |
Output is correct |
5 |
Correct |
183 ms |
2644 KB |
Output is correct |
6 |
Correct |
197 ms |
2644 KB |
Output is correct |
7 |
Correct |
180 ms |
2644 KB |
Output is correct |
8 |
Correct |
201 ms |
2644 KB |
Output is correct |
9 |
Correct |
185 ms |
2644 KB |
Output is correct |
10 |
Correct |
185 ms |
2644 KB |
Output is correct |
11 |
Execution timed out |
2067 ms |
2644 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |