답안 #340308

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
340308 2020-12-27T12:02:45 Z apostoldaniel854 Mountains (NOI20_mountains) C++14
100 / 100
611 ms 29548 KB
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

int n;

const int MAX_N = 3e5;
int aibL[1 + MAX_N], aibR[1 + MAX_N];
ll h[1 + MAX_N];

void upd (int pos, int val, int aib[]) {
    while (pos <= n) {
        aib[pos] += val;
        pos += pos & -pos;
    }
}
int qry (int pos, int aib[]) {
    int ans = 0;
    while (pos) {
        ans += aib[pos];
        pos -= pos & -pos;
    }
    return ans;
}

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);
    cin >> n;
    map <ll, int> mp;
    for (int i = 1; i <= n; i++)
        cin >> h[i], mp[h[i]];
    int nr = 0;
    for (auto &x : mp)
        x.second = ++nr;
    for (int i = 1; i <= n; i++)
        h[i] = mp[h[i]];
    for (int i = 2; i <= n; i++)
        upd (h[i], 1, aibR);
    upd (h[1], 1, aibL);
    ll ans = 0;
    for (int i = 2; i <= n; i++) {
        upd (h[i], -1, aibR);
        ans += 1ll * qry (h[i] - 1, aibL) * qry (h[i] - 1, aibR);
        upd (h[i], 1, aibL);
    }
    cout << ans << "\n";
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 201 ms 29292 KB Output is correct
3 Correct 202 ms 29292 KB Output is correct
4 Correct 199 ms 29292 KB Output is correct
5 Correct 201 ms 29292 KB Output is correct
6 Correct 198 ms 29292 KB Output is correct
7 Correct 203 ms 29388 KB Output is correct
8 Correct 198 ms 29292 KB Output is correct
9 Correct 180 ms 19308 KB Output is correct
10 Correct 170 ms 19180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3308 KB Output is correct
2 Correct 61 ms 3308 KB Output is correct
3 Correct 63 ms 3308 KB Output is correct
4 Correct 62 ms 3308 KB Output is correct
5 Correct 61 ms 3308 KB Output is correct
6 Correct 61 ms 3308 KB Output is correct
7 Correct 61 ms 3308 KB Output is correct
8 Correct 59 ms 3308 KB Output is correct
9 Correct 58 ms 3308 KB Output is correct
10 Correct 1 ms 416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3308 KB Output is correct
2 Correct 61 ms 3308 KB Output is correct
3 Correct 63 ms 3308 KB Output is correct
4 Correct 62 ms 3308 KB Output is correct
5 Correct 61 ms 3308 KB Output is correct
6 Correct 61 ms 3308 KB Output is correct
7 Correct 61 ms 3308 KB Output is correct
8 Correct 59 ms 3308 KB Output is correct
9 Correct 58 ms 3308 KB Output is correct
10 Correct 1 ms 416 KB Output is correct
11 Correct 82 ms 3792 KB Output is correct
12 Correct 83 ms 3692 KB Output is correct
13 Correct 82 ms 3692 KB Output is correct
14 Correct 81 ms 3564 KB Output is correct
15 Correct 81 ms 3564 KB Output is correct
16 Correct 80 ms 3564 KB Output is correct
17 Correct 80 ms 3564 KB Output is correct
18 Correct 58 ms 3564 KB Output is correct
19 Correct 58 ms 3564 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 7 ms 1260 KB Output is correct
12 Correct 7 ms 1260 KB Output is correct
13 Correct 7 ms 1260 KB Output is correct
14 Correct 8 ms 1260 KB Output is correct
15 Correct 7 ms 1260 KB Output is correct
16 Correct 7 ms 1260 KB Output is correct
17 Correct 7 ms 1260 KB Output is correct
18 Correct 6 ms 876 KB Output is correct
19 Correct 4 ms 492 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 60 ms 3308 KB Output is correct
2 Correct 61 ms 3308 KB Output is correct
3 Correct 63 ms 3308 KB Output is correct
4 Correct 62 ms 3308 KB Output is correct
5 Correct 61 ms 3308 KB Output is correct
6 Correct 61 ms 3308 KB Output is correct
7 Correct 61 ms 3308 KB Output is correct
8 Correct 59 ms 3308 KB Output is correct
9 Correct 58 ms 3308 KB Output is correct
10 Correct 1 ms 416 KB Output is correct
11 Correct 82 ms 3792 KB Output is correct
12 Correct 83 ms 3692 KB Output is correct
13 Correct 82 ms 3692 KB Output is correct
14 Correct 81 ms 3564 KB Output is correct
15 Correct 81 ms 3564 KB Output is correct
16 Correct 80 ms 3564 KB Output is correct
17 Correct 80 ms 3564 KB Output is correct
18 Correct 58 ms 3564 KB Output is correct
19 Correct 58 ms 3564 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 306 ms 11188 KB Output is correct
22 Correct 358 ms 11176 KB Output is correct
23 Correct 294 ms 11116 KB Output is correct
24 Correct 299 ms 11244 KB Output is correct
25 Correct 302 ms 11116 KB Output is correct
26 Correct 314 ms 11244 KB Output is correct
27 Correct 298 ms 11244 KB Output is correct
28 Correct 124 ms 11116 KB Output is correct
29 Correct 121 ms 11188 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 201 ms 29292 KB Output is correct
3 Correct 202 ms 29292 KB Output is correct
4 Correct 199 ms 29292 KB Output is correct
5 Correct 201 ms 29292 KB Output is correct
6 Correct 198 ms 29292 KB Output is correct
7 Correct 203 ms 29388 KB Output is correct
8 Correct 198 ms 29292 KB Output is correct
9 Correct 180 ms 19308 KB Output is correct
10 Correct 170 ms 19180 KB Output is correct
11 Correct 60 ms 3308 KB Output is correct
12 Correct 61 ms 3308 KB Output is correct
13 Correct 63 ms 3308 KB Output is correct
14 Correct 62 ms 3308 KB Output is correct
15 Correct 61 ms 3308 KB Output is correct
16 Correct 61 ms 3308 KB Output is correct
17 Correct 61 ms 3308 KB Output is correct
18 Correct 59 ms 3308 KB Output is correct
19 Correct 58 ms 3308 KB Output is correct
20 Correct 1 ms 416 KB Output is correct
21 Correct 82 ms 3792 KB Output is correct
22 Correct 83 ms 3692 KB Output is correct
23 Correct 82 ms 3692 KB Output is correct
24 Correct 81 ms 3564 KB Output is correct
25 Correct 81 ms 3564 KB Output is correct
26 Correct 80 ms 3564 KB Output is correct
27 Correct 80 ms 3564 KB Output is correct
28 Correct 58 ms 3564 KB Output is correct
29 Correct 58 ms 3564 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Correct 1 ms 364 KB Output is correct
32 Correct 1 ms 364 KB Output is correct
33 Correct 1 ms 364 KB Output is correct
34 Correct 1 ms 364 KB Output is correct
35 Correct 1 ms 364 KB Output is correct
36 Correct 1 ms 364 KB Output is correct
37 Correct 1 ms 364 KB Output is correct
38 Correct 1 ms 364 KB Output is correct
39 Correct 1 ms 364 KB Output is correct
40 Correct 1 ms 364 KB Output is correct
41 Correct 7 ms 1260 KB Output is correct
42 Correct 7 ms 1260 KB Output is correct
43 Correct 7 ms 1260 KB Output is correct
44 Correct 8 ms 1260 KB Output is correct
45 Correct 7 ms 1260 KB Output is correct
46 Correct 7 ms 1260 KB Output is correct
47 Correct 7 ms 1260 KB Output is correct
48 Correct 6 ms 876 KB Output is correct
49 Correct 4 ms 492 KB Output is correct
50 Correct 1 ms 364 KB Output is correct
51 Correct 306 ms 11188 KB Output is correct
52 Correct 358 ms 11176 KB Output is correct
53 Correct 294 ms 11116 KB Output is correct
54 Correct 299 ms 11244 KB Output is correct
55 Correct 302 ms 11116 KB Output is correct
56 Correct 314 ms 11244 KB Output is correct
57 Correct 298 ms 11244 KB Output is correct
58 Correct 124 ms 11116 KB Output is correct
59 Correct 121 ms 11188 KB Output is correct
60 Correct 1 ms 364 KB Output is correct
61 Correct 611 ms 29292 KB Output is correct
62 Correct 574 ms 29292 KB Output is correct
63 Correct 574 ms 29548 KB Output is correct
64 Correct 570 ms 29548 KB Output is correct
65 Correct 571 ms 29292 KB Output is correct
66 Correct 565 ms 29292 KB Output is correct
67 Correct 580 ms 29292 KB Output is correct
68 Correct 438 ms 19296 KB Output is correct
69 Correct 348 ms 13676 KB Output is correct
70 Correct 1 ms 364 KB Output is correct