#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
ll n;
cin>>n;
vector<ll> v(n);
bool ban=true;
for(ll i=0; i<n; i++){
cin>>v[i];
if(i>0 && ban==true){
if(v[i]<v[i-1]) 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;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
206 ms |
2644 KB |
Output is correct |
3 |
Correct |
198 ms |
2644 KB |
Output is correct |
4 |
Correct |
200 ms |
2644 KB |
Output is correct |
5 |
Correct |
192 ms |
2644 KB |
Output is correct |
6 |
Correct |
201 ms |
2644 KB |
Output is correct |
7 |
Correct |
192 ms |
2644 KB |
Output is correct |
8 |
Correct |
182 ms |
2644 KB |
Output is correct |
9 |
Correct |
201 ms |
2644 KB |
Output is correct |
10 |
Correct |
201 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2096 ms |
2644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2096 ms |
2644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
300 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
78 ms |
352 KB |
Output is correct |
12 |
Correct |
78 ms |
340 KB |
Output is correct |
13 |
Correct |
79 ms |
360 KB |
Output is correct |
14 |
Correct |
81 ms |
372 KB |
Output is correct |
15 |
Correct |
76 ms |
368 KB |
Output is correct |
16 |
Correct |
87 ms |
356 KB |
Output is correct |
17 |
Correct |
92 ms |
356 KB |
Output is correct |
18 |
Correct |
79 ms |
340 KB |
Output is correct |
19 |
Correct |
72 ms |
340 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2096 ms |
2644 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
206 ms |
2644 KB |
Output is correct |
3 |
Correct |
198 ms |
2644 KB |
Output is correct |
4 |
Correct |
200 ms |
2644 KB |
Output is correct |
5 |
Correct |
192 ms |
2644 KB |
Output is correct |
6 |
Correct |
201 ms |
2644 KB |
Output is correct |
7 |
Correct |
192 ms |
2644 KB |
Output is correct |
8 |
Correct |
182 ms |
2644 KB |
Output is correct |
9 |
Correct |
201 ms |
2644 KB |
Output is correct |
10 |
Correct |
201 ms |
2644 KB |
Output is correct |
11 |
Execution timed out |
2096 ms |
2644 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |