# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
329178 | 2020-11-19T15:31:35 Z | oak | Mountains (NOI20_mountains) | C++14 | 561 ms | 28780 KB |
#include<bits/stdc++.h> #define si 300000 using namespace std; int fw[si+1]; long long arr[si+1],db[si+1],sum[si+1]; void upd(int po,int val){ for(;po<=si;po+=(po&-po)){ fw[po]+=val; } } int qry(int po){ int ret = 0; for(;po>=1;po-=(po&-po)){ ret += fw[po]; } return ret; } int main(){ int n,j,i; scanf("%d",&n); map<long long,int> mp; int rl[n]; for(i=0;i<n;i++){ scanf("%lld",&arr[i]); db[i] = arr[i]; } sort(db,db+n); int co = 1; for(i=0;i<n;i++){ if(mp.find(db[i]) != mp.end())continue; mp[db[i]] = co; co++; } for(i=0;i<n;i++){ rl[i] = mp[arr[i]]; } for(i=0;i<n;i++){ sum[i] = qry(rl[i]-1); upd(rl[i],1); } long long ans = 0; memset(fw,0,sizeof fw); for(i=n-1;i>=0;i--){ sum[i] *= qry(rl[i]-1); upd(rl[i],1); ans += sum[i]*1ll; } printf("%lld",ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1516 KB | Output is correct |
2 | Correct | 249 ms | 28524 KB | Output is correct |
3 | Correct | 243 ms | 28524 KB | Output is correct |
4 | Correct | 242 ms | 28524 KB | Output is correct |
5 | Correct | 244 ms | 28524 KB | Output is correct |
6 | Correct | 243 ms | 28524 KB | Output is correct |
7 | Correct | 242 ms | 28652 KB | Output is correct |
8 | Correct | 242 ms | 28524 KB | Output is correct |
9 | Correct | 220 ms | 19436 KB | Output is correct |
10 | Correct | 203 ms | 19436 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 9708 KB | Output is correct |
2 | Correct | 71 ms | 9708 KB | Output is correct |
3 | Correct | 73 ms | 9720 KB | Output is correct |
4 | Correct | 72 ms | 9708 KB | Output is correct |
5 | Correct | 72 ms | 9856 KB | Output is correct |
6 | Correct | 84 ms | 9708 KB | Output is correct |
7 | Correct | 72 ms | 9708 KB | Output is correct |
8 | Correct | 68 ms | 9756 KB | Output is correct |
9 | Correct | 68 ms | 9836 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 9708 KB | Output is correct |
2 | Correct | 71 ms | 9708 KB | Output is correct |
3 | Correct | 73 ms | 9720 KB | Output is correct |
4 | Correct | 72 ms | 9708 KB | Output is correct |
5 | Correct | 72 ms | 9856 KB | Output is correct |
6 | Correct | 84 ms | 9708 KB | Output is correct |
7 | Correct | 72 ms | 9708 KB | Output is correct |
8 | Correct | 68 ms | 9756 KB | Output is correct |
9 | Correct | 68 ms | 9836 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
11 | Correct | 88 ms | 9692 KB | Output is correct |
12 | Correct | 88 ms | 9708 KB | Output is correct |
13 | Correct | 88 ms | 9708 KB | Output is correct |
14 | Correct | 86 ms | 9708 KB | Output is correct |
15 | Correct | 88 ms | 9708 KB | Output is correct |
16 | Correct | 88 ms | 9708 KB | Output is correct |
17 | Correct | 90 ms | 9688 KB | Output is correct |
18 | Correct | 66 ms | 9708 KB | Output is correct |
19 | Correct | 67 ms | 9708 KB | Output is correct |
20 | Correct | 1 ms | 1516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1516 KB | Output is correct |
2 | Correct | 1 ms | 1516 KB | Output is correct |
3 | Correct | 1 ms | 1516 KB | Output is correct |
4 | Correct | 1 ms | 1516 KB | Output is correct |
5 | Correct | 1 ms | 1516 KB | Output is correct |
6 | Correct | 2 ms | 1644 KB | Output is correct |
7 | Correct | 1 ms | 1516 KB | Output is correct |
8 | Correct | 1 ms | 1516 KB | Output is correct |
9 | Correct | 1 ms | 1516 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1516 KB | Output is correct |
2 | Correct | 1 ms | 1516 KB | Output is correct |
3 | Correct | 1 ms | 1516 KB | Output is correct |
4 | Correct | 1 ms | 1516 KB | Output is correct |
5 | Correct | 1 ms | 1516 KB | Output is correct |
6 | Correct | 2 ms | 1644 KB | Output is correct |
7 | Correct | 1 ms | 1516 KB | Output is correct |
8 | Correct | 1 ms | 1516 KB | Output is correct |
9 | Correct | 1 ms | 1516 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
11 | Correct | 9 ms | 2412 KB | Output is correct |
12 | Correct | 9 ms | 2412 KB | Output is correct |
13 | Correct | 9 ms | 2412 KB | Output is correct |
14 | Correct | 9 ms | 2412 KB | Output is correct |
15 | Correct | 9 ms | 2412 KB | Output is correct |
16 | Correct | 9 ms | 2412 KB | Output is correct |
17 | Correct | 10 ms | 2412 KB | Output is correct |
18 | Correct | 8 ms | 2028 KB | Output is correct |
19 | Correct | 5 ms | 1772 KB | Output is correct |
20 | Correct | 1 ms | 1516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 72 ms | 9708 KB | Output is correct |
2 | Correct | 71 ms | 9708 KB | Output is correct |
3 | Correct | 73 ms | 9720 KB | Output is correct |
4 | Correct | 72 ms | 9708 KB | Output is correct |
5 | Correct | 72 ms | 9856 KB | Output is correct |
6 | Correct | 84 ms | 9708 KB | Output is correct |
7 | Correct | 72 ms | 9708 KB | Output is correct |
8 | Correct | 68 ms | 9756 KB | Output is correct |
9 | Correct | 68 ms | 9836 KB | Output is correct |
10 | Correct | 1 ms | 1516 KB | Output is correct |
11 | Correct | 88 ms | 9692 KB | Output is correct |
12 | Correct | 88 ms | 9708 KB | Output is correct |
13 | Correct | 88 ms | 9708 KB | Output is correct |
14 | Correct | 86 ms | 9708 KB | Output is correct |
15 | Correct | 88 ms | 9708 KB | Output is correct |
16 | Correct | 88 ms | 9708 KB | Output is correct |
17 | Correct | 90 ms | 9688 KB | Output is correct |
18 | Correct | 66 ms | 9708 KB | Output is correct |
19 | Correct | 67 ms | 9708 KB | Output is correct |
20 | Correct | 1 ms | 1516 KB | Output is correct |
21 | Correct | 287 ms | 15596 KB | Output is correct |
22 | Correct | 296 ms | 15724 KB | Output is correct |
23 | Correct | 296 ms | 15724 KB | Output is correct |
24 | Correct | 303 ms | 15660 KB | Output is correct |
25 | Correct | 307 ms | 15596 KB | Output is correct |
26 | Correct | 306 ms | 15724 KB | Output is correct |
27 | Correct | 301 ms | 15620 KB | Output is correct |
28 | Correct | 148 ms | 15596 KB | Output is correct |
29 | Correct | 148 ms | 15596 KB | Output is correct |
30 | Correct | 1 ms | 1516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1516 KB | Output is correct |
2 | Correct | 249 ms | 28524 KB | Output is correct |
3 | Correct | 243 ms | 28524 KB | Output is correct |
4 | Correct | 242 ms | 28524 KB | Output is correct |
5 | Correct | 244 ms | 28524 KB | Output is correct |
6 | Correct | 243 ms | 28524 KB | Output is correct |
7 | Correct | 242 ms | 28652 KB | Output is correct |
8 | Correct | 242 ms | 28524 KB | Output is correct |
9 | Correct | 220 ms | 19436 KB | Output is correct |
10 | Correct | 203 ms | 19436 KB | Output is correct |
11 | Correct | 72 ms | 9708 KB | Output is correct |
12 | Correct | 71 ms | 9708 KB | Output is correct |
13 | Correct | 73 ms | 9720 KB | Output is correct |
14 | Correct | 72 ms | 9708 KB | Output is correct |
15 | Correct | 72 ms | 9856 KB | Output is correct |
16 | Correct | 84 ms | 9708 KB | Output is correct |
17 | Correct | 72 ms | 9708 KB | Output is correct |
18 | Correct | 68 ms | 9756 KB | Output is correct |
19 | Correct | 68 ms | 9836 KB | Output is correct |
20 | Correct | 1 ms | 1516 KB | Output is correct |
21 | Correct | 88 ms | 9692 KB | Output is correct |
22 | Correct | 88 ms | 9708 KB | Output is correct |
23 | Correct | 88 ms | 9708 KB | Output is correct |
24 | Correct | 86 ms | 9708 KB | Output is correct |
25 | Correct | 88 ms | 9708 KB | Output is correct |
26 | Correct | 88 ms | 9708 KB | Output is correct |
27 | Correct | 90 ms | 9688 KB | Output is correct |
28 | Correct | 66 ms | 9708 KB | Output is correct |
29 | Correct | 67 ms | 9708 KB | Output is correct |
30 | Correct | 1 ms | 1516 KB | Output is correct |
31 | Correct | 1 ms | 1516 KB | Output is correct |
32 | Correct | 1 ms | 1516 KB | Output is correct |
33 | Correct | 1 ms | 1516 KB | Output is correct |
34 | Correct | 1 ms | 1516 KB | Output is correct |
35 | Correct | 1 ms | 1516 KB | Output is correct |
36 | Correct | 2 ms | 1644 KB | Output is correct |
37 | Correct | 1 ms | 1516 KB | Output is correct |
38 | Correct | 1 ms | 1516 KB | Output is correct |
39 | Correct | 1 ms | 1516 KB | Output is correct |
40 | Correct | 1 ms | 1516 KB | Output is correct |
41 | Correct | 9 ms | 2412 KB | Output is correct |
42 | Correct | 9 ms | 2412 KB | Output is correct |
43 | Correct | 9 ms | 2412 KB | Output is correct |
44 | Correct | 9 ms | 2412 KB | Output is correct |
45 | Correct | 9 ms | 2412 KB | Output is correct |
46 | Correct | 9 ms | 2412 KB | Output is correct |
47 | Correct | 10 ms | 2412 KB | Output is correct |
48 | Correct | 8 ms | 2028 KB | Output is correct |
49 | Correct | 5 ms | 1772 KB | Output is correct |
50 | Correct | 1 ms | 1516 KB | Output is correct |
51 | Correct | 287 ms | 15596 KB | Output is correct |
52 | Correct | 296 ms | 15724 KB | Output is correct |
53 | Correct | 296 ms | 15724 KB | Output is correct |
54 | Correct | 303 ms | 15660 KB | Output is correct |
55 | Correct | 307 ms | 15596 KB | Output is correct |
56 | Correct | 306 ms | 15724 KB | Output is correct |
57 | Correct | 301 ms | 15620 KB | Output is correct |
58 | Correct | 148 ms | 15596 KB | Output is correct |
59 | Correct | 148 ms | 15596 KB | Output is correct |
60 | Correct | 1 ms | 1516 KB | Output is correct |
61 | Correct | 554 ms | 28548 KB | Output is correct |
62 | Correct | 545 ms | 28516 KB | Output is correct |
63 | Correct | 557 ms | 28780 KB | Output is correct |
64 | Correct | 552 ms | 28652 KB | Output is correct |
65 | Correct | 543 ms | 28640 KB | Output is correct |
66 | Correct | 561 ms | 28484 KB | Output is correct |
67 | Correct | 545 ms | 28524 KB | Output is correct |
68 | Correct | 419 ms | 19392 KB | Output is correct |
69 | Correct | 375 ms | 17772 KB | Output is correct |
70 | Correct | 1 ms | 1516 KB | Output is correct |