#include <bits/stdc++.h>
using namespace std;
vector <long long int> v, aux;
int main() {
long long int n, a, c=0, md=0, mi=0;
bool sorted=true;
cin >> n;
for (long long int i=0; i<n; i++){
cin >> a;
v.push_back(a);
aux.push_back(a);
}
sort (aux.begin(), aux.end());
for (int i=0; i<n; i++) if (v[i]!=aux[i]) sorted = false;
if (sorted==true) {
cout << 0;
return 0;
}
for (long long int y=1; y<n-1; y++){
for (int i=y-1; i>=0; i--) if (v[i]<v[y]) mi++;
if (mi!=0){
for (int i=y+1; i<n; i++) if (v[i]<v[y]) md++;
c+=mi*md;
mi=0;
md=0;
}
}
cout << c;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
191 ms |
6644 KB |
Output is correct |
3 |
Correct |
202 ms |
6604 KB |
Output is correct |
4 |
Correct |
189 ms |
6572 KB |
Output is correct |
5 |
Correct |
191 ms |
6584 KB |
Output is correct |
6 |
Correct |
215 ms |
6604 KB |
Output is correct |
7 |
Correct |
188 ms |
6604 KB |
Output is correct |
8 |
Correct |
200 ms |
6672 KB |
Output is correct |
9 |
Correct |
205 ms |
6632 KB |
Output is correct |
10 |
Correct |
190 ms |
6672 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
6624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
6624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
2 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
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 |
2 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 |
178 ms |
596 KB |
Output is correct |
12 |
Correct |
205 ms |
596 KB |
Output is correct |
13 |
Correct |
186 ms |
596 KB |
Output is correct |
14 |
Correct |
176 ms |
596 KB |
Output is correct |
15 |
Correct |
184 ms |
596 KB |
Output is correct |
16 |
Correct |
181 ms |
596 KB |
Output is correct |
17 |
Correct |
179 ms |
596 KB |
Output is correct |
18 |
Correct |
188 ms |
596 KB |
Output is correct |
19 |
Correct |
173 ms |
596 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
2075 ms |
6624 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
191 ms |
6644 KB |
Output is correct |
3 |
Correct |
202 ms |
6604 KB |
Output is correct |
4 |
Correct |
189 ms |
6572 KB |
Output is correct |
5 |
Correct |
191 ms |
6584 KB |
Output is correct |
6 |
Correct |
215 ms |
6604 KB |
Output is correct |
7 |
Correct |
188 ms |
6604 KB |
Output is correct |
8 |
Correct |
200 ms |
6672 KB |
Output is correct |
9 |
Correct |
205 ms |
6632 KB |
Output is correct |
10 |
Correct |
190 ms |
6672 KB |
Output is correct |
11 |
Execution timed out |
2075 ms |
6624 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |