Submission #259697

# Submission time Handle Problem Language Result Execution time Memory
259697 2020-08-08T10:00:14 Z IOrtroiii Mountains (NOI20_mountains) C++14
100 / 100
817 ms 29688 KB
#include <bits/stdc++.h>

#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

using namespace __gnu_pbds;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main() {
   ios_base::sync_with_stdio(false); cin.tie(nullptr);
   int N; cin >> N;
   vector<int64_t> H(N);
   for (int i = 0; i < N; ++i) cin >> H[i];
   vector<int> L(N), R(N);
   ordered_set<pair<int64_t, int>> st;
   for (int i = 0; i < N; ++i) {
      L[i] = st.order_of_key({H[i], -1});
      st.insert({H[i], i});
   }
   st.clear();
   for (int i = N - 1; i >= 0; --i) {
      R[i] = st.order_of_key({H[i], -1});
      st.insert({H[i], i});
   }
   int64_t ans = 0;
   for (int i = 0; i < N; ++i) ans += int64_t(L[i]) * R[i];
   cout << ans << '\n';
   return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 510 ms 29308 KB Output is correct
3 Correct 499 ms 29304 KB Output is correct
4 Correct 492 ms 29308 KB Output is correct
5 Correct 495 ms 29480 KB Output is correct
6 Correct 498 ms 29304 KB Output is correct
7 Correct 520 ms 29332 KB Output is correct
8 Correct 495 ms 29424 KB Output is correct
9 Correct 509 ms 29432 KB Output is correct
10 Correct 492 ms 29432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 335 ms 23928 KB Output is correct
2 Correct 316 ms 23800 KB Output is correct
3 Correct 321 ms 23928 KB Output is correct
4 Correct 324 ms 23800 KB Output is correct
5 Correct 323 ms 23800 KB Output is correct
6 Correct 326 ms 23800 KB Output is correct
7 Correct 329 ms 23800 KB Output is correct
8 Correct 452 ms 23928 KB Output is correct
9 Correct 451 ms 23856 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 335 ms 23928 KB Output is correct
2 Correct 316 ms 23800 KB Output is correct
3 Correct 321 ms 23928 KB Output is correct
4 Correct 324 ms 23800 KB Output is correct
5 Correct 323 ms 23800 KB Output is correct
6 Correct 326 ms 23800 KB Output is correct
7 Correct 329 ms 23800 KB Output is correct
8 Correct 452 ms 23928 KB Output is correct
9 Correct 451 ms 23856 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 613 ms 23800 KB Output is correct
12 Correct 612 ms 23800 KB Output is correct
13 Correct 607 ms 23800 KB Output is correct
14 Correct 618 ms 23800 KB Output is correct
15 Correct 619 ms 23800 KB Output is correct
16 Correct 603 ms 23928 KB Output is correct
17 Correct 608 ms 23932 KB Output is correct
18 Correct 452 ms 23804 KB Output is correct
19 Correct 442 ms 23800 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 11 ms 1280 KB Output is correct
12 Correct 11 ms 1408 KB Output is correct
13 Correct 11 ms 1280 KB Output is correct
14 Correct 13 ms 1280 KB Output is correct
15 Correct 11 ms 1280 KB Output is correct
16 Correct 11 ms 1280 KB Output is correct
17 Correct 11 ms 1280 KB Output is correct
18 Correct 12 ms 1280 KB Output is correct
19 Correct 10 ms 1152 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 335 ms 23928 KB Output is correct
2 Correct 316 ms 23800 KB Output is correct
3 Correct 321 ms 23928 KB Output is correct
4 Correct 324 ms 23800 KB Output is correct
5 Correct 323 ms 23800 KB Output is correct
6 Correct 326 ms 23800 KB Output is correct
7 Correct 329 ms 23800 KB Output is correct
8 Correct 452 ms 23928 KB Output is correct
9 Correct 451 ms 23856 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 613 ms 23800 KB Output is correct
12 Correct 612 ms 23800 KB Output is correct
13 Correct 607 ms 23800 KB Output is correct
14 Correct 618 ms 23800 KB Output is correct
15 Correct 619 ms 23800 KB Output is correct
16 Correct 603 ms 23928 KB Output is correct
17 Correct 608 ms 23932 KB Output is correct
18 Correct 452 ms 23804 KB Output is correct
19 Correct 442 ms 23800 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 778 ms 23992 KB Output is correct
22 Correct 760 ms 23800 KB Output is correct
23 Correct 696 ms 23972 KB Output is correct
24 Correct 705 ms 23800 KB Output is correct
25 Correct 747 ms 23928 KB Output is correct
26 Correct 734 ms 23928 KB Output is correct
27 Correct 691 ms 23928 KB Output is correct
28 Correct 470 ms 23800 KB Output is correct
29 Correct 473 ms 23800 KB Output is correct
30 Correct 0 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 510 ms 29308 KB Output is correct
3 Correct 499 ms 29304 KB Output is correct
4 Correct 492 ms 29308 KB Output is correct
5 Correct 495 ms 29480 KB Output is correct
6 Correct 498 ms 29304 KB Output is correct
7 Correct 520 ms 29332 KB Output is correct
8 Correct 495 ms 29424 KB Output is correct
9 Correct 509 ms 29432 KB Output is correct
10 Correct 492 ms 29432 KB Output is correct
11 Correct 335 ms 23928 KB Output is correct
12 Correct 316 ms 23800 KB Output is correct
13 Correct 321 ms 23928 KB Output is correct
14 Correct 324 ms 23800 KB Output is correct
15 Correct 323 ms 23800 KB Output is correct
16 Correct 326 ms 23800 KB Output is correct
17 Correct 329 ms 23800 KB Output is correct
18 Correct 452 ms 23928 KB Output is correct
19 Correct 451 ms 23856 KB Output is correct
20 Correct 1 ms 384 KB Output is correct
21 Correct 613 ms 23800 KB Output is correct
22 Correct 612 ms 23800 KB Output is correct
23 Correct 607 ms 23800 KB Output is correct
24 Correct 618 ms 23800 KB Output is correct
25 Correct 619 ms 23800 KB Output is correct
26 Correct 603 ms 23928 KB Output is correct
27 Correct 608 ms 23932 KB Output is correct
28 Correct 452 ms 23804 KB Output is correct
29 Correct 442 ms 23800 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 11 ms 1280 KB Output is correct
42 Correct 11 ms 1408 KB Output is correct
43 Correct 11 ms 1280 KB Output is correct
44 Correct 13 ms 1280 KB Output is correct
45 Correct 11 ms 1280 KB Output is correct
46 Correct 11 ms 1280 KB Output is correct
47 Correct 11 ms 1280 KB Output is correct
48 Correct 12 ms 1280 KB Output is correct
49 Correct 10 ms 1152 KB Output is correct
50 Correct 0 ms 384 KB Output is correct
51 Correct 778 ms 23992 KB Output is correct
52 Correct 760 ms 23800 KB Output is correct
53 Correct 696 ms 23972 KB Output is correct
54 Correct 705 ms 23800 KB Output is correct
55 Correct 747 ms 23928 KB Output is correct
56 Correct 734 ms 23928 KB Output is correct
57 Correct 691 ms 23928 KB Output is correct
58 Correct 470 ms 23800 KB Output is correct
59 Correct 473 ms 23800 KB Output is correct
60 Correct 0 ms 384 KB Output is correct
61 Correct 707 ms 29432 KB Output is correct
62 Correct 722 ms 29560 KB Output is correct
63 Correct 712 ms 29688 KB Output is correct
64 Correct 697 ms 29436 KB Output is correct
65 Correct 731 ms 29304 KB Output is correct
66 Correct 763 ms 29560 KB Output is correct
67 Correct 768 ms 29512 KB Output is correct
68 Correct 817 ms 29432 KB Output is correct
69 Correct 684 ms 25824 KB Output is correct
70 Correct 1 ms 384 KB Output is correct