#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
long long int c[300000];
long long int mn[300000];
int t[100];
int main(){
int n;
cin >> n;
long long int ans = 0;
if(n >= 10005){
cin >> c[0];
if(c[0] >= 100){
cout << 0;
return 0;
}
t[c[0]]++;
mn[0] = 0;
for(int i = 1; i < n; i++){
cin >> c[i];
if(c[i] >= 100){
cout << 0;
return 0;
}
for(int j = 0; j < c[i]; j++){
mn[i] += t[j];
}
t[c[i]]++;
}
memset(t, 0, sizeof(t[0])* 100);
t[c[n - 1]]++;
for(int i = n - 2; i >= 0; i--){
long long int temp =0;
for(int j = 0; j < c[i]; j++){
temp += t[j];
}
ans += mn[i] * temp;
t[c[i]]++;
}
cout << ans;
}
else{
for(int i = 0; i < n; i++){
cin >> c[i];
}
for(int i = 1; i < n - 1; i++){
long long int a = 0, b = 0;
for(int j = 0; j < i; j++){
if(c[j] < c[i])a++;
}
for(int j = i + 1; j < n; j++){
if(c[j] < c[i])b++;
}
ans += a * b;
}
cout << ans;
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
4920 KB |
Output is correct |
2 |
Correct |
67 ms |
5068 KB |
Output is correct |
3 |
Correct |
60 ms |
4932 KB |
Output is correct |
4 |
Correct |
61 ms |
4872 KB |
Output is correct |
5 |
Correct |
65 ms |
4964 KB |
Output is correct |
6 |
Correct |
81 ms |
4868 KB |
Output is correct |
7 |
Correct |
67 ms |
4960 KB |
Output is correct |
8 |
Correct |
62 ms |
3692 KB |
Output is correct |
9 |
Correct |
58 ms |
3756 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
4920 KB |
Output is correct |
2 |
Correct |
67 ms |
5068 KB |
Output is correct |
3 |
Correct |
60 ms |
4932 KB |
Output is correct |
4 |
Correct |
61 ms |
4872 KB |
Output is correct |
5 |
Correct |
65 ms |
4964 KB |
Output is correct |
6 |
Correct |
81 ms |
4868 KB |
Output is correct |
7 |
Correct |
67 ms |
4960 KB |
Output is correct |
8 |
Correct |
62 ms |
3692 KB |
Output is correct |
9 |
Correct |
58 ms |
3756 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
127 ms |
4968 KB |
Output is correct |
12 |
Correct |
131 ms |
4964 KB |
Output is correct |
13 |
Correct |
119 ms |
4868 KB |
Output is correct |
14 |
Correct |
97 ms |
4992 KB |
Output is correct |
15 |
Correct |
122 ms |
4968 KB |
Output is correct |
16 |
Correct |
96 ms |
4956 KB |
Output is correct |
17 |
Correct |
122 ms |
4872 KB |
Output is correct |
18 |
Correct |
93 ms |
4888 KB |
Output is correct |
19 |
Correct |
108 ms |
4868 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
204 KB |
Output is correct |
4 |
Correct |
1 ms |
204 KB |
Output is correct |
5 |
Correct |
1 ms |
204 KB |
Output is correct |
6 |
Correct |
1 ms |
204 KB |
Output is correct |
7 |
Correct |
1 ms |
204 KB |
Output is correct |
8 |
Correct |
1 ms |
204 KB |
Output is correct |
9 |
Correct |
1 ms |
204 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
89 ms |
372 KB |
Output is correct |
12 |
Correct |
84 ms |
332 KB |
Output is correct |
13 |
Correct |
89 ms |
360 KB |
Output is correct |
14 |
Correct |
84 ms |
360 KB |
Output is correct |
15 |
Correct |
86 ms |
332 KB |
Output is correct |
16 |
Correct |
86 ms |
364 KB |
Output is correct |
17 |
Correct |
85 ms |
332 KB |
Output is correct |
18 |
Correct |
103 ms |
332 KB |
Output is correct |
19 |
Correct |
90 ms |
360 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
58 ms |
4920 KB |
Output is correct |
2 |
Correct |
67 ms |
5068 KB |
Output is correct |
3 |
Correct |
60 ms |
4932 KB |
Output is correct |
4 |
Correct |
61 ms |
4872 KB |
Output is correct |
5 |
Correct |
65 ms |
4964 KB |
Output is correct |
6 |
Correct |
81 ms |
4868 KB |
Output is correct |
7 |
Correct |
67 ms |
4960 KB |
Output is correct |
8 |
Correct |
62 ms |
3692 KB |
Output is correct |
9 |
Correct |
58 ms |
3756 KB |
Output is correct |
10 |
Correct |
1 ms |
204 KB |
Output is correct |
11 |
Correct |
127 ms |
4968 KB |
Output is correct |
12 |
Correct |
131 ms |
4964 KB |
Output is correct |
13 |
Correct |
119 ms |
4868 KB |
Output is correct |
14 |
Correct |
97 ms |
4992 KB |
Output is correct |
15 |
Correct |
122 ms |
4968 KB |
Output is correct |
16 |
Correct |
96 ms |
4956 KB |
Output is correct |
17 |
Correct |
122 ms |
4872 KB |
Output is correct |
18 |
Correct |
93 ms |
4888 KB |
Output is correct |
19 |
Correct |
108 ms |
4868 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
22 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
312 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
316 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
58 ms |
4920 KB |
Output is correct |
12 |
Correct |
67 ms |
5068 KB |
Output is correct |
13 |
Correct |
60 ms |
4932 KB |
Output is correct |
14 |
Correct |
61 ms |
4872 KB |
Output is correct |
15 |
Correct |
65 ms |
4964 KB |
Output is correct |
16 |
Correct |
81 ms |
4868 KB |
Output is correct |
17 |
Correct |
67 ms |
4960 KB |
Output is correct |
18 |
Correct |
62 ms |
3692 KB |
Output is correct |
19 |
Correct |
58 ms |
3756 KB |
Output is correct |
20 |
Correct |
1 ms |
204 KB |
Output is correct |
21 |
Correct |
127 ms |
4968 KB |
Output is correct |
22 |
Correct |
131 ms |
4964 KB |
Output is correct |
23 |
Correct |
119 ms |
4868 KB |
Output is correct |
24 |
Correct |
97 ms |
4992 KB |
Output is correct |
25 |
Correct |
122 ms |
4968 KB |
Output is correct |
26 |
Correct |
96 ms |
4956 KB |
Output is correct |
27 |
Correct |
122 ms |
4872 KB |
Output is correct |
28 |
Correct |
93 ms |
4888 KB |
Output is correct |
29 |
Correct |
108 ms |
4868 KB |
Output is correct |
30 |
Correct |
1 ms |
204 KB |
Output is correct |
31 |
Correct |
2 ms |
204 KB |
Output is correct |
32 |
Correct |
1 ms |
204 KB |
Output is correct |
33 |
Correct |
1 ms |
204 KB |
Output is correct |
34 |
Correct |
1 ms |
204 KB |
Output is correct |
35 |
Correct |
1 ms |
204 KB |
Output is correct |
36 |
Correct |
1 ms |
204 KB |
Output is correct |
37 |
Correct |
1 ms |
204 KB |
Output is correct |
38 |
Correct |
1 ms |
204 KB |
Output is correct |
39 |
Correct |
1 ms |
204 KB |
Output is correct |
40 |
Correct |
1 ms |
204 KB |
Output is correct |
41 |
Correct |
89 ms |
372 KB |
Output is correct |
42 |
Correct |
84 ms |
332 KB |
Output is correct |
43 |
Correct |
89 ms |
360 KB |
Output is correct |
44 |
Correct |
84 ms |
360 KB |
Output is correct |
45 |
Correct |
86 ms |
332 KB |
Output is correct |
46 |
Correct |
86 ms |
364 KB |
Output is correct |
47 |
Correct |
85 ms |
332 KB |
Output is correct |
48 |
Correct |
103 ms |
332 KB |
Output is correct |
49 |
Correct |
90 ms |
360 KB |
Output is correct |
50 |
Correct |
1 ms |
204 KB |
Output is correct |
51 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
52 |
Halted |
0 ms |
0 KB |
- |