# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
295385 | 2020-09-09T16:13:51 Z | beso123 | Mountains (NOI20_mountains) | C++14 | 533 ms | 20192 KB |
#include <bits/stdc++.h> #define int long long #define pii pair<int,int> #define x first #define y second using namespace std; const int N=300005; int n,a[N],l[N],r[N]; int bit[N]; int GET(int i){ int sum=0; while(i>=1){ sum+=bit[i]; i=i-(i&(-i)); } return sum; } void UPD(int i,int val){ while(i<=n){ bit[i]+=val; i=i+(i&(-i)); } } vector<pii> v; main(){ cin>>n; for(int k=1;k<=n;k++) cin>>a[k]; for(int k=1;k<=n;k++){ v.push_back({a[k],k}); } sort(v.begin(),v.end()); a[v[0].y]=1; for(int k=1;k<v.size();k++){ a[v[k].y]=a[v[k-1].y]; if(v[k].x!=v[k-1].x) a[v[k].y]++; } UPD(a[1],1); for(int k=2;k<=n;k++){ l[k]=GET(a[k]-1); UPD(a[k],1); } for(int k=1;k<=n;k++) bit[k]=0; UPD(a[n],1); for(int k=n-1;k>=1;k--){ r[k]=GET(a[k]-1); UPD(a[k],1); } int ans=0; for(int k=1;k<=n;k++) ans+=l[k]*r[k]; cout<<ans; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 488 ms | 20048 KB | Output is correct |
3 | Correct | 484 ms | 20176 KB | Output is correct |
4 | Correct | 489 ms | 20048 KB | Output is correct |
5 | Correct | 495 ms | 20048 KB | Output is correct |
6 | Correct | 483 ms | 20052 KB | Output is correct |
7 | Correct | 480 ms | 20064 KB | Output is correct |
8 | Correct | 493 ms | 20176 KB | Output is correct |
9 | Correct | 499 ms | 20048 KB | Output is correct |
10 | Correct | 492 ms | 20176 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 156 ms | 15056 KB | Output is correct |
2 | Correct | 162 ms | 15184 KB | Output is correct |
3 | Correct | 162 ms | 15108 KB | Output is correct |
4 | Correct | 155 ms | 15052 KB | Output is correct |
5 | Correct | 157 ms | 15056 KB | Output is correct |
6 | Correct | 155 ms | 15056 KB | Output is correct |
7 | Correct | 155 ms | 15056 KB | Output is correct |
8 | Correct | 141 ms | 15056 KB | Output is correct |
9 | Correct | 138 ms | 15184 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 156 ms | 15056 KB | Output is correct |
2 | Correct | 162 ms | 15184 KB | Output is correct |
3 | Correct | 162 ms | 15108 KB | Output is correct |
4 | Correct | 155 ms | 15052 KB | Output is correct |
5 | Correct | 157 ms | 15056 KB | Output is correct |
6 | Correct | 155 ms | 15056 KB | Output is correct |
7 | Correct | 155 ms | 15056 KB | Output is correct |
8 | Correct | 141 ms | 15056 KB | Output is correct |
9 | Correct | 138 ms | 15184 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 178 ms | 15364 KB | Output is correct |
12 | Correct | 186 ms | 15440 KB | Output is correct |
13 | Correct | 178 ms | 15440 KB | Output is correct |
14 | Correct | 175 ms | 15440 KB | Output is correct |
15 | Correct | 177 ms | 15440 KB | Output is correct |
16 | Correct | 178 ms | 15440 KB | Output is correct |
17 | Correct | 177 ms | 15440 KB | Output is correct |
18 | Correct | 153 ms | 15312 KB | Output is correct |
19 | Correct | 162 ms | 15440 KB | Output is correct |
20 | 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 |
# | 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 | 17 ms | 1148 KB | Output is correct |
12 | Correct | 17 ms | 1148 KB | Output is correct |
13 | Correct | 17 ms | 1148 KB | Output is correct |
14 | Correct | 17 ms | 1148 KB | Output is correct |
15 | Correct | 17 ms | 1140 KB | Output is correct |
16 | Correct | 18 ms | 1148 KB | Output is correct |
17 | Correct | 17 ms | 1148 KB | Output is correct |
18 | Correct | 17 ms | 1148 KB | Output is correct |
19 | Correct | 6 ms | 1020 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 156 ms | 15056 KB | Output is correct |
2 | Correct | 162 ms | 15184 KB | Output is correct |
3 | Correct | 162 ms | 15108 KB | Output is correct |
4 | Correct | 155 ms | 15052 KB | Output is correct |
5 | Correct | 157 ms | 15056 KB | Output is correct |
6 | Correct | 155 ms | 15056 KB | Output is correct |
7 | Correct | 155 ms | 15056 KB | Output is correct |
8 | Correct | 141 ms | 15056 KB | Output is correct |
9 | Correct | 138 ms | 15184 KB | Output is correct |
10 | Correct | 1 ms | 384 KB | Output is correct |
11 | Correct | 178 ms | 15364 KB | Output is correct |
12 | Correct | 186 ms | 15440 KB | Output is correct |
13 | Correct | 178 ms | 15440 KB | Output is correct |
14 | Correct | 175 ms | 15440 KB | Output is correct |
15 | Correct | 177 ms | 15440 KB | Output is correct |
16 | Correct | 178 ms | 15440 KB | Output is correct |
17 | Correct | 177 ms | 15440 KB | Output is correct |
18 | Correct | 153 ms | 15312 KB | Output is correct |
19 | Correct | 162 ms | 15440 KB | Output is correct |
20 | Correct | 0 ms | 384 KB | Output is correct |
21 | Correct | 239 ms | 16336 KB | Output is correct |
22 | Correct | 243 ms | 16208 KB | Output is correct |
23 | Correct | 247 ms | 16284 KB | Output is correct |
24 | Correct | 241 ms | 16336 KB | Output is correct |
25 | Correct | 242 ms | 16208 KB | Output is correct |
26 | Correct | 242 ms | 16336 KB | Output is correct |
27 | Correct | 240 ms | 16336 KB | Output is correct |
28 | Correct | 212 ms | 16208 KB | Output is correct |
29 | Correct | 211 ms | 16464 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 | 488 ms | 20048 KB | Output is correct |
3 | Correct | 484 ms | 20176 KB | Output is correct |
4 | Correct | 489 ms | 20048 KB | Output is correct |
5 | Correct | 495 ms | 20048 KB | Output is correct |
6 | Correct | 483 ms | 20052 KB | Output is correct |
7 | Correct | 480 ms | 20064 KB | Output is correct |
8 | Correct | 493 ms | 20176 KB | Output is correct |
9 | Correct | 499 ms | 20048 KB | Output is correct |
10 | Correct | 492 ms | 20176 KB | Output is correct |
11 | Correct | 156 ms | 15056 KB | Output is correct |
12 | Correct | 162 ms | 15184 KB | Output is correct |
13 | Correct | 162 ms | 15108 KB | Output is correct |
14 | Correct | 155 ms | 15052 KB | Output is correct |
15 | Correct | 157 ms | 15056 KB | Output is correct |
16 | Correct | 155 ms | 15056 KB | Output is correct |
17 | Correct | 155 ms | 15056 KB | Output is correct |
18 | Correct | 141 ms | 15056 KB | Output is correct |
19 | Correct | 138 ms | 15184 KB | Output is correct |
20 | Correct | 1 ms | 384 KB | Output is correct |
21 | Correct | 178 ms | 15364 KB | Output is correct |
22 | Correct | 186 ms | 15440 KB | Output is correct |
23 | Correct | 178 ms | 15440 KB | Output is correct |
24 | Correct | 175 ms | 15440 KB | Output is correct |
25 | Correct | 177 ms | 15440 KB | Output is correct |
26 | Correct | 178 ms | 15440 KB | Output is correct |
27 | Correct | 177 ms | 15440 KB | Output is correct |
28 | Correct | 153 ms | 15312 KB | Output is correct |
29 | Correct | 162 ms | 15440 KB | Output is correct |
30 | Correct | 0 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 | 17 ms | 1148 KB | Output is correct |
42 | Correct | 17 ms | 1148 KB | Output is correct |
43 | Correct | 17 ms | 1148 KB | Output is correct |
44 | Correct | 17 ms | 1148 KB | Output is correct |
45 | Correct | 17 ms | 1140 KB | Output is correct |
46 | Correct | 18 ms | 1148 KB | Output is correct |
47 | Correct | 17 ms | 1148 KB | Output is correct |
48 | Correct | 17 ms | 1148 KB | Output is correct |
49 | Correct | 6 ms | 1020 KB | Output is correct |
50 | Correct | 0 ms | 384 KB | Output is correct |
51 | Correct | 239 ms | 16336 KB | Output is correct |
52 | Correct | 243 ms | 16208 KB | Output is correct |
53 | Correct | 247 ms | 16284 KB | Output is correct |
54 | Correct | 241 ms | 16336 KB | Output is correct |
55 | Correct | 242 ms | 16208 KB | Output is correct |
56 | Correct | 242 ms | 16336 KB | Output is correct |
57 | Correct | 240 ms | 16336 KB | Output is correct |
58 | Correct | 212 ms | 16208 KB | Output is correct |
59 | Correct | 211 ms | 16464 KB | Output is correct |
60 | Correct | 1 ms | 384 KB | Output is correct |
61 | Correct | 519 ms | 20176 KB | Output is correct |
62 | Correct | 512 ms | 20176 KB | Output is correct |
63 | Correct | 514 ms | 20176 KB | Output is correct |
64 | Correct | 511 ms | 20048 KB | Output is correct |
65 | Correct | 533 ms | 20176 KB | Output is correct |
66 | Correct | 511 ms | 20048 KB | Output is correct |
67 | Correct | 511 ms | 20048 KB | Output is correct |
68 | Correct | 526 ms | 20192 KB | Output is correct |
69 | Correct | 248 ms | 16592 KB | Output is correct |
70 | Correct | 1 ms | 384 KB | Output is correct |