#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, i, cont=0, a, b, j;
cin >> n;
ll xd[n];
bool lol=false;
for(i=0;i<n;i++) {
cin >> xd[i];
if(xd[i-1]>xd[i]) lol=true;
}
if(lol==false) {
cout << "0" << endl;
return 0;
}
for(i=1;i<n-1;i++) {
a=0;
b=0;
for(j=0;j<i;j++) {
if(xd[j]<xd[i]) a++;
}
for(j=i+1;j<n;j++) {
if(xd[j]<xd[i]) b++;
}
cont+=a*b;
}
cout << cont << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
185 ms |
2620 KB |
Output is correct |
3 |
Correct |
210 ms |
2616 KB |
Output is correct |
4 |
Correct |
181 ms |
2636 KB |
Output is correct |
5 |
Correct |
197 ms |
2516 KB |
Output is correct |
6 |
Correct |
185 ms |
2620 KB |
Output is correct |
7 |
Correct |
179 ms |
2620 KB |
Output is correct |
8 |
Correct |
189 ms |
2616 KB |
Output is correct |
9 |
Correct |
186 ms |
2616 KB |
Output is correct |
10 |
Correct |
187 ms |
2636 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2065 ms |
2516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2065 ms |
2516 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 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 |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
2 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
212 KB |
Output is correct |
5 |
Correct |
2 ms |
212 KB |
Output is correct |
6 |
Correct |
2 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
11 |
Correct |
316 ms |
348 KB |
Output is correct |
12 |
Correct |
319 ms |
348 KB |
Output is correct |
13 |
Correct |
307 ms |
352 KB |
Output is correct |
14 |
Correct |
304 ms |
340 KB |
Output is correct |
15 |
Correct |
318 ms |
344 KB |
Output is correct |
16 |
Correct |
309 ms |
460 KB |
Output is correct |
17 |
Correct |
305 ms |
352 KB |
Output is correct |
18 |
Correct |
316 ms |
348 KB |
Output is correct |
19 |
Correct |
295 ms |
344 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
2065 ms |
2516 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 |
185 ms |
2620 KB |
Output is correct |
3 |
Correct |
210 ms |
2616 KB |
Output is correct |
4 |
Correct |
181 ms |
2636 KB |
Output is correct |
5 |
Correct |
197 ms |
2516 KB |
Output is correct |
6 |
Correct |
185 ms |
2620 KB |
Output is correct |
7 |
Correct |
179 ms |
2620 KB |
Output is correct |
8 |
Correct |
189 ms |
2616 KB |
Output is correct |
9 |
Correct |
186 ms |
2616 KB |
Output is correct |
10 |
Correct |
187 ms |
2636 KB |
Output is correct |
11 |
Execution timed out |
2065 ms |
2516 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |