Submission #224847

# Submission time Handle Problem Language Result Execution time Memory
224847 2020-04-19T02:32:17 Z nabilervatra Mountains (NOI20_mountains) C++14
100 / 100
342 ms 24824 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set s;
long long n,ans;
pair<long long, long long > arr[300005];
int main(){
    ios_base::sync_with_stdio(NULL);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i =1;i<=n;i++){
        cin>>arr[i].fi;
        arr[i].se=i;
    }
    sort(arr+1,arr+n+1);
    long long bef=1;
    for(int i =2;i<=n;i++){
        if(arr[i].fi>arr[bef].fi){
            for(int j =bef;j<=i-1;j++)s.insert(arr[j].se);
            bef=i;
        }
        long long jwb1 = s.order_of_key(arr[i].se);
        long long jwb2 = s.size()-jwb1;
        ans += jwb1*jwb2;
    }
    cout<<ans<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 321 ms 24696 KB Output is correct
3 Correct 323 ms 24688 KB Output is correct
4 Correct 329 ms 24696 KB Output is correct
5 Correct 326 ms 24780 KB Output is correct
6 Correct 332 ms 24696 KB Output is correct
7 Correct 323 ms 24696 KB Output is correct
8 Correct 323 ms 24824 KB Output is correct
9 Correct 328 ms 24648 KB Output is correct
10 Correct 328 ms 24696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 12664 KB Output is correct
2 Correct 158 ms 12668 KB Output is correct
3 Correct 156 ms 12664 KB Output is correct
4 Correct 152 ms 12664 KB Output is correct
5 Correct 156 ms 12676 KB Output is correct
6 Correct 159 ms 12792 KB Output is correct
7 Correct 151 ms 12664 KB Output is correct
8 Correct 140 ms 12664 KB Output is correct
9 Correct 138 ms 12664 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 12664 KB Output is correct
2 Correct 158 ms 12668 KB Output is correct
3 Correct 156 ms 12664 KB Output is correct
4 Correct 152 ms 12664 KB Output is correct
5 Correct 156 ms 12676 KB Output is correct
6 Correct 159 ms 12792 KB Output is correct
7 Correct 151 ms 12664 KB Output is correct
8 Correct 140 ms 12664 KB Output is correct
9 Correct 138 ms 12664 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 230 ms 19960 KB Output is correct
12 Correct 228 ms 19940 KB Output is correct
13 Correct 229 ms 19832 KB Output is correct
14 Correct 227 ms 19940 KB Output is correct
15 Correct 221 ms 19832 KB Output is correct
16 Correct 221 ms 19832 KB Output is correct
17 Correct 222 ms 19960 KB Output is correct
18 Correct 282 ms 19832 KB Output is correct
19 Correct 282 ms 19960 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 11 ms 1152 KB Output is correct
12 Correct 11 ms 1152 KB Output is correct
13 Correct 11 ms 1152 KB Output is correct
14 Correct 11 ms 1152 KB Output is correct
15 Correct 11 ms 1152 KB Output is correct
16 Correct 15 ms 1152 KB Output is correct
17 Correct 11 ms 1152 KB Output is correct
18 Correct 11 ms 1152 KB Output is correct
19 Correct 11 ms 1024 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 151 ms 12664 KB Output is correct
2 Correct 158 ms 12668 KB Output is correct
3 Correct 156 ms 12664 KB Output is correct
4 Correct 152 ms 12664 KB Output is correct
5 Correct 156 ms 12676 KB Output is correct
6 Correct 159 ms 12792 KB Output is correct
7 Correct 151 ms 12664 KB Output is correct
8 Correct 140 ms 12664 KB Output is correct
9 Correct 138 ms 12664 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 230 ms 19960 KB Output is correct
12 Correct 228 ms 19940 KB Output is correct
13 Correct 229 ms 19832 KB Output is correct
14 Correct 227 ms 19940 KB Output is correct
15 Correct 221 ms 19832 KB Output is correct
16 Correct 221 ms 19832 KB Output is correct
17 Correct 222 ms 19960 KB Output is correct
18 Correct 282 ms 19832 KB Output is correct
19 Correct 282 ms 19960 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 342 ms 20856 KB Output is correct
22 Correct 323 ms 20856 KB Output is correct
23 Correct 301 ms 20984 KB Output is correct
24 Correct 302 ms 20856 KB Output is correct
25 Correct 301 ms 20856 KB Output is correct
26 Correct 308 ms 20984 KB Output is correct
27 Correct 306 ms 20984 KB Output is correct
28 Correct 289 ms 20856 KB Output is correct
29 Correct 298 ms 20856 KB Output is correct
30 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 321 ms 24696 KB Output is correct
3 Correct 323 ms 24688 KB Output is correct
4 Correct 329 ms 24696 KB Output is correct
5 Correct 326 ms 24780 KB Output is correct
6 Correct 332 ms 24696 KB Output is correct
7 Correct 323 ms 24696 KB Output is correct
8 Correct 323 ms 24824 KB Output is correct
9 Correct 328 ms 24648 KB Output is correct
10 Correct 328 ms 24696 KB Output is correct
11 Correct 151 ms 12664 KB Output is correct
12 Correct 158 ms 12668 KB Output is correct
13 Correct 156 ms 12664 KB Output is correct
14 Correct 152 ms 12664 KB Output is correct
15 Correct 156 ms 12676 KB Output is correct
16 Correct 159 ms 12792 KB Output is correct
17 Correct 151 ms 12664 KB Output is correct
18 Correct 140 ms 12664 KB Output is correct
19 Correct 138 ms 12664 KB Output is correct
20 Correct 5 ms 384 KB Output is correct
21 Correct 230 ms 19960 KB Output is correct
22 Correct 228 ms 19940 KB Output is correct
23 Correct 229 ms 19832 KB Output is correct
24 Correct 227 ms 19940 KB Output is correct
25 Correct 221 ms 19832 KB Output is correct
26 Correct 221 ms 19832 KB Output is correct
27 Correct 222 ms 19960 KB Output is correct
28 Correct 282 ms 19832 KB Output is correct
29 Correct 282 ms 19960 KB Output is correct
30 Correct 5 ms 384 KB Output is correct
31 Correct 5 ms 384 KB Output is correct
32 Correct 5 ms 384 KB Output is correct
33 Correct 5 ms 384 KB Output is correct
34 Correct 5 ms 384 KB Output is correct
35 Correct 5 ms 384 KB Output is correct
36 Correct 5 ms 384 KB Output is correct
37 Correct 5 ms 384 KB Output is correct
38 Correct 5 ms 384 KB Output is correct
39 Correct 5 ms 384 KB Output is correct
40 Correct 4 ms 384 KB Output is correct
41 Correct 11 ms 1152 KB Output is correct
42 Correct 11 ms 1152 KB Output is correct
43 Correct 11 ms 1152 KB Output is correct
44 Correct 11 ms 1152 KB Output is correct
45 Correct 11 ms 1152 KB Output is correct
46 Correct 15 ms 1152 KB Output is correct
47 Correct 11 ms 1152 KB Output is correct
48 Correct 11 ms 1152 KB Output is correct
49 Correct 11 ms 1024 KB Output is correct
50 Correct 5 ms 384 KB Output is correct
51 Correct 342 ms 20856 KB Output is correct
52 Correct 323 ms 20856 KB Output is correct
53 Correct 301 ms 20984 KB Output is correct
54 Correct 302 ms 20856 KB Output is correct
55 Correct 301 ms 20856 KB Output is correct
56 Correct 308 ms 20984 KB Output is correct
57 Correct 306 ms 20984 KB Output is correct
58 Correct 289 ms 20856 KB Output is correct
59 Correct 298 ms 20856 KB Output is correct
60 Correct 4 ms 384 KB Output is correct
61 Correct 334 ms 24696 KB Output is correct
62 Correct 323 ms 24696 KB Output is correct
63 Correct 324 ms 24696 KB Output is correct
64 Correct 324 ms 24600 KB Output is correct
65 Correct 327 ms 24824 KB Output is correct
66 Correct 325 ms 24700 KB Output is correct
67 Correct 324 ms 24696 KB Output is correct
68 Correct 331 ms 24696 KB Output is correct
69 Correct 291 ms 20984 KB Output is correct
70 Correct 5 ms 384 KB Output is correct