# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
586498 | 2022-06-30T10:48:26 Z | krit3379 | Mountains (NOI20_mountains) | C++17 | 783 ms | 34076 KB |
#include<bits/stdc++.h> using namespace std; #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") #define N 300005 long long a[N],fen[N],l[N],r[N],ans; map<long long,int> mp; void upd(int x){ while(x<N){ fen[x]++; x+=x&-x; } } long long sol(int x){ long long ans=0; while(x){ ans+=fen[x]; x-=x&-x; } return ans; } int main(){ int n,i; scanf("%d",&n); for(i=1;i<=n;i++)scanf("%lld",&a[i]),mp[a[i]]; i=0; for(auto &[x,y]:mp)y=++i; for(i=1;i<=n;i++){ l[i]=sol(mp[a[i]]); upd(mp[a[i]]+1); } for(i=1;i<=n;i++)fen[i]=0; for(i=n;i;i--){ r[i]=sol(mp[a[i]]); upd(mp[a[i]]+1); } for(i=1;i<=n;i++)ans+=l[i]*r[i]; printf("%lld",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 281 ms | 33996 KB | Output is correct |
3 | Correct | 290 ms | 33976 KB | Output is correct |
4 | Correct | 268 ms | 33924 KB | Output is correct |
5 | Correct | 279 ms | 33992 KB | Output is correct |
6 | Correct | 291 ms | 33984 KB | Output is correct |
7 | Correct | 275 ms | 33996 KB | Output is correct |
8 | Correct | 289 ms | 33940 KB | Output is correct |
9 | Correct | 232 ms | 24888 KB | Output is correct |
10 | Correct | 233 ms | 24948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 10232 KB | Output is correct |
2 | Correct | 57 ms | 10156 KB | Output is correct |
3 | Correct | 64 ms | 10160 KB | Output is correct |
4 | Correct | 54 ms | 10252 KB | Output is correct |
5 | Correct | 54 ms | 10168 KB | Output is correct |
6 | Correct | 52 ms | 10212 KB | Output is correct |
7 | Correct | 59 ms | 10216 KB | Output is correct |
8 | Correct | 57 ms | 10232 KB | Output is correct |
9 | Correct | 54 ms | 10184 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 10232 KB | Output is correct |
2 | Correct | 57 ms | 10156 KB | Output is correct |
3 | Correct | 64 ms | 10160 KB | Output is correct |
4 | Correct | 54 ms | 10252 KB | Output is correct |
5 | Correct | 54 ms | 10168 KB | Output is correct |
6 | Correct | 52 ms | 10212 KB | Output is correct |
7 | Correct | 59 ms | 10216 KB | Output is correct |
8 | Correct | 57 ms | 10232 KB | Output is correct |
9 | Correct | 54 ms | 10184 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 86 ms | 10428 KB | Output is correct |
12 | Correct | 94 ms | 10420 KB | Output is correct |
13 | Correct | 91 ms | 10520 KB | Output is correct |
14 | Correct | 84 ms | 10440 KB | Output is correct |
15 | Correct | 79 ms | 10464 KB | Output is correct |
16 | Correct | 83 ms | 10440 KB | Output is correct |
17 | Correct | 81 ms | 10444 KB | Output is correct |
18 | Correct | 62 ms | 10524 KB | Output is correct |
19 | Correct | 57 ms | 10468 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 420 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 316 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 420 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 340 KB | Output is correct |
8 | Correct | 1 ms | 316 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
11 | Correct | 9 ms | 1420 KB | Output is correct |
12 | Correct | 10 ms | 1364 KB | Output is correct |
13 | Correct | 10 ms | 1364 KB | Output is correct |
14 | Correct | 11 ms | 1464 KB | Output is correct |
15 | Correct | 13 ms | 1444 KB | Output is correct |
16 | Correct | 10 ms | 1388 KB | Output is correct |
17 | Correct | 9 ms | 1420 KB | Output is correct |
18 | Correct | 7 ms | 1108 KB | Output is correct |
19 | Correct | 4 ms | 700 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 55 ms | 10232 KB | Output is correct |
2 | Correct | 57 ms | 10156 KB | Output is correct |
3 | Correct | 64 ms | 10160 KB | Output is correct |
4 | Correct | 54 ms | 10252 KB | Output is correct |
5 | Correct | 54 ms | 10168 KB | Output is correct |
6 | Correct | 52 ms | 10212 KB | Output is correct |
7 | Correct | 59 ms | 10216 KB | Output is correct |
8 | Correct | 57 ms | 10232 KB | Output is correct |
9 | Correct | 54 ms | 10184 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 86 ms | 10428 KB | Output is correct |
12 | Correct | 94 ms | 10420 KB | Output is correct |
13 | Correct | 91 ms | 10520 KB | Output is correct |
14 | Correct | 84 ms | 10440 KB | Output is correct |
15 | Correct | 79 ms | 10464 KB | Output is correct |
16 | Correct | 83 ms | 10440 KB | Output is correct |
17 | Correct | 81 ms | 10444 KB | Output is correct |
18 | Correct | 62 ms | 10524 KB | Output is correct |
19 | Correct | 57 ms | 10468 KB | Output is correct |
20 | Correct | 0 ms | 340 KB | Output is correct |
21 | Correct | 433 ms | 17492 KB | Output is correct |
22 | Correct | 412 ms | 17232 KB | Output is correct |
23 | Correct | 421 ms | 17348 KB | Output is correct |
24 | Correct | 422 ms | 17328 KB | Output is correct |
25 | Correct | 367 ms | 17324 KB | Output is correct |
26 | Correct | 384 ms | 17260 KB | Output is correct |
27 | Correct | 370 ms | 17232 KB | Output is correct |
28 | Correct | 182 ms | 17388 KB | Output is correct |
29 | Correct | 192 ms | 17252 KB | Output is correct |
30 | Correct | 1 ms | 308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 340 KB | Output is correct |
2 | Correct | 281 ms | 33996 KB | Output is correct |
3 | Correct | 290 ms | 33976 KB | Output is correct |
4 | Correct | 268 ms | 33924 KB | Output is correct |
5 | Correct | 279 ms | 33992 KB | Output is correct |
6 | Correct | 291 ms | 33984 KB | Output is correct |
7 | Correct | 275 ms | 33996 KB | Output is correct |
8 | Correct | 289 ms | 33940 KB | Output is correct |
9 | Correct | 232 ms | 24888 KB | Output is correct |
10 | Correct | 233 ms | 24948 KB | Output is correct |
11 | Correct | 55 ms | 10232 KB | Output is correct |
12 | Correct | 57 ms | 10156 KB | Output is correct |
13 | Correct | 64 ms | 10160 KB | Output is correct |
14 | Correct | 54 ms | 10252 KB | Output is correct |
15 | Correct | 54 ms | 10168 KB | Output is correct |
16 | Correct | 52 ms | 10212 KB | Output is correct |
17 | Correct | 59 ms | 10216 KB | Output is correct |
18 | Correct | 57 ms | 10232 KB | Output is correct |
19 | Correct | 54 ms | 10184 KB | Output is correct |
20 | Correct | 1 ms | 340 KB | Output is correct |
21 | Correct | 86 ms | 10428 KB | Output is correct |
22 | Correct | 94 ms | 10420 KB | Output is correct |
23 | Correct | 91 ms | 10520 KB | Output is correct |
24 | Correct | 84 ms | 10440 KB | Output is correct |
25 | Correct | 79 ms | 10464 KB | Output is correct |
26 | Correct | 83 ms | 10440 KB | Output is correct |
27 | Correct | 81 ms | 10444 KB | Output is correct |
28 | Correct | 62 ms | 10524 KB | Output is correct |
29 | Correct | 57 ms | 10468 KB | Output is correct |
30 | Correct | 0 ms | 340 KB | Output is correct |
31 | Correct | 1 ms | 340 KB | Output is correct |
32 | Correct | 1 ms | 420 KB | Output is correct |
33 | Correct | 1 ms | 340 KB | Output is correct |
34 | Correct | 1 ms | 340 KB | Output is correct |
35 | Correct | 1 ms | 340 KB | Output is correct |
36 | Correct | 1 ms | 340 KB | Output is correct |
37 | Correct | 1 ms | 340 KB | Output is correct |
38 | Correct | 1 ms | 316 KB | Output is correct |
39 | Correct | 1 ms | 340 KB | Output is correct |
40 | Correct | 0 ms | 308 KB | Output is correct |
41 | Correct | 9 ms | 1420 KB | Output is correct |
42 | Correct | 10 ms | 1364 KB | Output is correct |
43 | Correct | 10 ms | 1364 KB | Output is correct |
44 | Correct | 11 ms | 1464 KB | Output is correct |
45 | Correct | 13 ms | 1444 KB | Output is correct |
46 | Correct | 10 ms | 1388 KB | Output is correct |
47 | Correct | 9 ms | 1420 KB | Output is correct |
48 | Correct | 7 ms | 1108 KB | Output is correct |
49 | Correct | 4 ms | 700 KB | Output is correct |
50 | Correct | 1 ms | 340 KB | Output is correct |
51 | Correct | 433 ms | 17492 KB | Output is correct |
52 | Correct | 412 ms | 17232 KB | Output is correct |
53 | Correct | 421 ms | 17348 KB | Output is correct |
54 | Correct | 422 ms | 17328 KB | Output is correct |
55 | Correct | 367 ms | 17324 KB | Output is correct |
56 | Correct | 384 ms | 17260 KB | Output is correct |
57 | Correct | 370 ms | 17232 KB | Output is correct |
58 | Correct | 182 ms | 17388 KB | Output is correct |
59 | Correct | 192 ms | 17252 KB | Output is correct |
60 | Correct | 1 ms | 308 KB | Output is correct |
61 | Correct | 776 ms | 33992 KB | Output is correct |
62 | Correct | 743 ms | 34076 KB | Output is correct |
63 | Correct | 740 ms | 34048 KB | Output is correct |
64 | Correct | 747 ms | 34028 KB | Output is correct |
65 | Correct | 783 ms | 33964 KB | Output is correct |
66 | Correct | 733 ms | 33952 KB | Output is correct |
67 | Correct | 753 ms | 33952 KB | Output is correct |
68 | Correct | 520 ms | 24948 KB | Output is correct |
69 | Correct | 456 ms | 19568 KB | Output is correct |
70 | Correct | 1 ms | 340 KB | Output is correct |