#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,lf[300009],rg[300009],f[300009],fen[300009],pas;
map <long long, long long> m;
map <long long, long long>::iterator it;
void upd(long long q){
while(q<=a+1){
fen[q]++;
q=q+(q&(-q));
}
}
long long read(long long q){
long long jm=0;
while(q>=1){
jm+=fen[q];
q=q-(q&(-q));
}
return jm;
}
int main(){
ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
cin>>a;
for(i=1; i<=a; i++){
cin>>f[i];
m[f[i]]=1;
}
zx=0;
for(it=m.begin(); it!=m.end(); it++){
zx++;
m[(*it).first]=zx;
}
for(i=1; i<=a; i++) f[i]=m[f[i]];
for(i=0; i<=a+2; i++) fen[i]=0;
for(i=1; i<=a; i++){
lf[i]=read(f[i]-1);
upd(f[i]);
}
for(i=0; i<=a+2; i++) fen[i]=0;
for(i=a; i>=1; i--){
rg[i]=read(f[i]-1);
upd(f[i]);
}
for(i=1; i<=a; i++){
pas+=lf[i]*rg[i];
}
cout<<pas;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
238 ms |
34008 KB |
Output is correct |
3 |
Correct |
237 ms |
34040 KB |
Output is correct |
4 |
Correct |
244 ms |
34040 KB |
Output is correct |
5 |
Correct |
253 ms |
34168 KB |
Output is correct |
6 |
Correct |
235 ms |
34040 KB |
Output is correct |
7 |
Correct |
245 ms |
34068 KB |
Output is correct |
8 |
Correct |
266 ms |
34088 KB |
Output is correct |
9 |
Correct |
197 ms |
24964 KB |
Output is correct |
10 |
Correct |
206 ms |
25080 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
10360 KB |
Output is correct |
2 |
Correct |
63 ms |
10360 KB |
Output is correct |
3 |
Correct |
62 ms |
10260 KB |
Output is correct |
4 |
Correct |
84 ms |
10360 KB |
Output is correct |
5 |
Correct |
65 ms |
10364 KB |
Output is correct |
6 |
Correct |
64 ms |
10360 KB |
Output is correct |
7 |
Correct |
76 ms |
10360 KB |
Output is correct |
8 |
Correct |
72 ms |
10360 KB |
Output is correct |
9 |
Correct |
67 ms |
10360 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
10360 KB |
Output is correct |
2 |
Correct |
63 ms |
10360 KB |
Output is correct |
3 |
Correct |
62 ms |
10260 KB |
Output is correct |
4 |
Correct |
84 ms |
10360 KB |
Output is correct |
5 |
Correct |
65 ms |
10364 KB |
Output is correct |
6 |
Correct |
64 ms |
10360 KB |
Output is correct |
7 |
Correct |
76 ms |
10360 KB |
Output is correct |
8 |
Correct |
72 ms |
10360 KB |
Output is correct |
9 |
Correct |
67 ms |
10360 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
82 ms |
10620 KB |
Output is correct |
12 |
Correct |
84 ms |
10616 KB |
Output is correct |
13 |
Correct |
91 ms |
10616 KB |
Output is correct |
14 |
Correct |
85 ms |
10616 KB |
Output is correct |
15 |
Correct |
87 ms |
10616 KB |
Output is correct |
16 |
Correct |
85 ms |
10616 KB |
Output is correct |
17 |
Correct |
82 ms |
10616 KB |
Output is correct |
18 |
Correct |
64 ms |
10616 KB |
Output is correct |
19 |
Correct |
61 ms |
10616 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
8 ms |
1536 KB |
Output is correct |
12 |
Correct |
8 ms |
1440 KB |
Output is correct |
13 |
Correct |
10 ms |
1536 KB |
Output is correct |
14 |
Correct |
8 ms |
1536 KB |
Output is correct |
15 |
Correct |
8 ms |
1536 KB |
Output is correct |
16 |
Correct |
8 ms |
1460 KB |
Output is correct |
17 |
Correct |
8 ms |
1536 KB |
Output is correct |
18 |
Correct |
6 ms |
1152 KB |
Output is correct |
19 |
Correct |
4 ms |
768 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
66 ms |
10360 KB |
Output is correct |
2 |
Correct |
63 ms |
10360 KB |
Output is correct |
3 |
Correct |
62 ms |
10260 KB |
Output is correct |
4 |
Correct |
84 ms |
10360 KB |
Output is correct |
5 |
Correct |
65 ms |
10364 KB |
Output is correct |
6 |
Correct |
64 ms |
10360 KB |
Output is correct |
7 |
Correct |
76 ms |
10360 KB |
Output is correct |
8 |
Correct |
72 ms |
10360 KB |
Output is correct |
9 |
Correct |
67 ms |
10360 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Correct |
82 ms |
10620 KB |
Output is correct |
12 |
Correct |
84 ms |
10616 KB |
Output is correct |
13 |
Correct |
91 ms |
10616 KB |
Output is correct |
14 |
Correct |
85 ms |
10616 KB |
Output is correct |
15 |
Correct |
87 ms |
10616 KB |
Output is correct |
16 |
Correct |
85 ms |
10616 KB |
Output is correct |
17 |
Correct |
82 ms |
10616 KB |
Output is correct |
18 |
Correct |
64 ms |
10616 KB |
Output is correct |
19 |
Correct |
61 ms |
10616 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
325 ms |
17528 KB |
Output is correct |
22 |
Correct |
329 ms |
17400 KB |
Output is correct |
23 |
Correct |
333 ms |
17448 KB |
Output is correct |
24 |
Correct |
333 ms |
17400 KB |
Output is correct |
25 |
Correct |
344 ms |
17400 KB |
Output is correct |
26 |
Correct |
338 ms |
17400 KB |
Output is correct |
27 |
Correct |
348 ms |
17528 KB |
Output is correct |
28 |
Correct |
141 ms |
17400 KB |
Output is correct |
29 |
Correct |
142 ms |
17392 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
238 ms |
34008 KB |
Output is correct |
3 |
Correct |
237 ms |
34040 KB |
Output is correct |
4 |
Correct |
244 ms |
34040 KB |
Output is correct |
5 |
Correct |
253 ms |
34168 KB |
Output is correct |
6 |
Correct |
235 ms |
34040 KB |
Output is correct |
7 |
Correct |
245 ms |
34068 KB |
Output is correct |
8 |
Correct |
266 ms |
34088 KB |
Output is correct |
9 |
Correct |
197 ms |
24964 KB |
Output is correct |
10 |
Correct |
206 ms |
25080 KB |
Output is correct |
11 |
Correct |
66 ms |
10360 KB |
Output is correct |
12 |
Correct |
63 ms |
10360 KB |
Output is correct |
13 |
Correct |
62 ms |
10260 KB |
Output is correct |
14 |
Correct |
84 ms |
10360 KB |
Output is correct |
15 |
Correct |
65 ms |
10364 KB |
Output is correct |
16 |
Correct |
64 ms |
10360 KB |
Output is correct |
17 |
Correct |
76 ms |
10360 KB |
Output is correct |
18 |
Correct |
72 ms |
10360 KB |
Output is correct |
19 |
Correct |
67 ms |
10360 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
82 ms |
10620 KB |
Output is correct |
22 |
Correct |
84 ms |
10616 KB |
Output is correct |
23 |
Correct |
91 ms |
10616 KB |
Output is correct |
24 |
Correct |
85 ms |
10616 KB |
Output is correct |
25 |
Correct |
87 ms |
10616 KB |
Output is correct |
26 |
Correct |
85 ms |
10616 KB |
Output is correct |
27 |
Correct |
82 ms |
10616 KB |
Output is correct |
28 |
Correct |
64 ms |
10616 KB |
Output is correct |
29 |
Correct |
61 ms |
10616 KB |
Output is correct |
30 |
Correct |
1 ms |
384 KB |
Output is correct |
31 |
Correct |
1 ms |
384 KB |
Output is correct |
32 |
Correct |
1 ms |
384 KB |
Output is correct |
33 |
Correct |
1 ms |
384 KB |
Output is correct |
34 |
Correct |
1 ms |
384 KB |
Output is correct |
35 |
Correct |
1 ms |
384 KB |
Output is correct |
36 |
Correct |
1 ms |
384 KB |
Output is correct |
37 |
Correct |
1 ms |
384 KB |
Output is correct |
38 |
Correct |
1 ms |
384 KB |
Output is correct |
39 |
Correct |
1 ms |
384 KB |
Output is correct |
40 |
Correct |
0 ms |
384 KB |
Output is correct |
41 |
Correct |
8 ms |
1536 KB |
Output is correct |
42 |
Correct |
8 ms |
1440 KB |
Output is correct |
43 |
Correct |
10 ms |
1536 KB |
Output is correct |
44 |
Correct |
8 ms |
1536 KB |
Output is correct |
45 |
Correct |
8 ms |
1536 KB |
Output is correct |
46 |
Correct |
8 ms |
1460 KB |
Output is correct |
47 |
Correct |
8 ms |
1536 KB |
Output is correct |
48 |
Correct |
6 ms |
1152 KB |
Output is correct |
49 |
Correct |
4 ms |
768 KB |
Output is correct |
50 |
Correct |
1 ms |
384 KB |
Output is correct |
51 |
Correct |
325 ms |
17528 KB |
Output is correct |
52 |
Correct |
329 ms |
17400 KB |
Output is correct |
53 |
Correct |
333 ms |
17448 KB |
Output is correct |
54 |
Correct |
333 ms |
17400 KB |
Output is correct |
55 |
Correct |
344 ms |
17400 KB |
Output is correct |
56 |
Correct |
338 ms |
17400 KB |
Output is correct |
57 |
Correct |
348 ms |
17528 KB |
Output is correct |
58 |
Correct |
141 ms |
17400 KB |
Output is correct |
59 |
Correct |
142 ms |
17392 KB |
Output is correct |
60 |
Correct |
1 ms |
384 KB |
Output is correct |
61 |
Correct |
659 ms |
34124 KB |
Output is correct |
62 |
Correct |
651 ms |
34040 KB |
Output is correct |
63 |
Correct |
633 ms |
33988 KB |
Output is correct |
64 |
Correct |
640 ms |
34128 KB |
Output is correct |
65 |
Correct |
576 ms |
34088 KB |
Output is correct |
66 |
Correct |
597 ms |
33992 KB |
Output is correct |
67 |
Correct |
607 ms |
34080 KB |
Output is correct |
68 |
Correct |
472 ms |
24952 KB |
Output is correct |
69 |
Correct |
397 ms |
19704 KB |
Output is correct |
70 |
Correct |
1 ms |
384 KB |
Output is correct |