답안 #337659

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337659 2020-12-21T11:18:48 Z Vladth11 Mountains (NOI20_mountains) C++14
24 / 100
142 ms 8348 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define debug(x) cerr << #x << " " << x << "\n"
#define debug_with_space(x) cerr << #x << " " << x << " "

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair <ll, ll> pii;
typedef pair <ll, pii> piii;
typedef tree <pii, null_type, less <pii>, rb_tree_tag, tree_order_statistics_node_update> OST;

const ll NMAX = 300001;
const ll INF = 1e9;
const ll MOD = 1000000007;
const ll BLOCK = 101;
const ll nr_of_bits = 35;

struct ura{
    int i, v, idx;
} v[NMAX];

bool cmp(ura a, ura b){
    return a.i < b.i;
}

bool cmpp(ura a, ura b){
    return a.idx < b.idx;
}

int st[NMAX], n, dr[NMAX];
int aib[NMAX + 5];

void update(int x, int val){
    for(int i = x; i <= n; i += i&(-i))
        aib[i] += val;
}

int query(int x){
    int val = 0;
    for(int i = x; i > 0; i -= i&(-i))
        val += aib[i];
    return val;
}


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int i;
    cin >> n;
    for(i = 1; i <= n; i++){
        cin >> v[i].i;
        v[i].idx = i;
    }
    int cnt = 1;
    sort(v + 1, v + n + 1, cmp);
    for(i = 1; i <= n; i++){
        if(i > 1 && v[i].i != v[i - 1].i)
            cnt++;
        v[i].v = cnt;
    }
    sort(v + 1, v + n + 1, cmpp);
    for(i = 1; i <= n; i++){
        update(v[i].v, 1);
        st[i] = query(v[i].v - 1);
    }
    ll sol = 0;
    for(i = 1; i <= n; i++){
        update(v[i].v, -1);
    }
    for(i = n; i >= 1; i--){
        update(v[i].v, 1);
        dr[i] = query(v[i].v - 1);
        sol += 1LL * st[i] * dr[i];
    }
    cout << sol;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 89 ms 6252 KB Output is correct
3 Correct 91 ms 6248 KB Output is correct
4 Correct 89 ms 6252 KB Output is correct
5 Correct 88 ms 6252 KB Output is correct
6 Correct 88 ms 6252 KB Output is correct
7 Correct 90 ms 6252 KB Output is correct
8 Correct 89 ms 6252 KB Output is correct
9 Correct 91 ms 6252 KB Output is correct
10 Correct 89 ms 6252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 6892 KB Output is correct
2 Correct 114 ms 6892 KB Output is correct
3 Correct 115 ms 6892 KB Output is correct
4 Correct 113 ms 6908 KB Output is correct
5 Correct 115 ms 6892 KB Output is correct
6 Correct 114 ms 7020 KB Output is correct
7 Correct 116 ms 6892 KB Output is correct
8 Correct 106 ms 6892 KB Output is correct
9 Correct 108 ms 6892 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 6892 KB Output is correct
2 Correct 114 ms 6892 KB Output is correct
3 Correct 115 ms 6892 KB Output is correct
4 Correct 113 ms 6908 KB Output is correct
5 Correct 115 ms 6892 KB Output is correct
6 Correct 114 ms 7020 KB Output is correct
7 Correct 116 ms 6892 KB Output is correct
8 Correct 106 ms 6892 KB Output is correct
9 Correct 108 ms 6892 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 124 ms 7148 KB Output is correct
12 Correct 126 ms 7148 KB Output is correct
13 Correct 127 ms 7148 KB Output is correct
14 Correct 128 ms 7148 KB Output is correct
15 Correct 128 ms 7152 KB Output is correct
16 Correct 128 ms 7340 KB Output is correct
17 Correct 126 ms 7148 KB Output is correct
18 Correct 96 ms 7148 KB Output is correct
19 Correct 97 ms 7148 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 116 ms 6892 KB Output is correct
2 Correct 114 ms 6892 KB Output is correct
3 Correct 115 ms 6892 KB Output is correct
4 Correct 113 ms 6908 KB Output is correct
5 Correct 115 ms 6892 KB Output is correct
6 Correct 114 ms 7020 KB Output is correct
7 Correct 116 ms 6892 KB Output is correct
8 Correct 106 ms 6892 KB Output is correct
9 Correct 108 ms 6892 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 124 ms 7148 KB Output is correct
12 Correct 126 ms 7148 KB Output is correct
13 Correct 127 ms 7148 KB Output is correct
14 Correct 128 ms 7148 KB Output is correct
15 Correct 128 ms 7152 KB Output is correct
16 Correct 128 ms 7340 KB Output is correct
17 Correct 126 ms 7148 KB Output is correct
18 Correct 96 ms 7148 KB Output is correct
19 Correct 97 ms 7148 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 140 ms 8300 KB Output is correct
22 Correct 140 ms 8300 KB Output is correct
23 Correct 140 ms 8348 KB Output is correct
24 Correct 141 ms 8300 KB Output is correct
25 Correct 138 ms 8300 KB Output is correct
26 Correct 139 ms 8300 KB Output is correct
27 Correct 142 ms 8300 KB Output is correct
28 Correct 97 ms 8344 KB Output is correct
29 Correct 99 ms 8300 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 89 ms 6252 KB Output is correct
3 Correct 91 ms 6248 KB Output is correct
4 Correct 89 ms 6252 KB Output is correct
5 Correct 88 ms 6252 KB Output is correct
6 Correct 88 ms 6252 KB Output is correct
7 Correct 90 ms 6252 KB Output is correct
8 Correct 89 ms 6252 KB Output is correct
9 Correct 91 ms 6252 KB Output is correct
10 Correct 89 ms 6252 KB Output is correct
11 Correct 116 ms 6892 KB Output is correct
12 Correct 114 ms 6892 KB Output is correct
13 Correct 115 ms 6892 KB Output is correct
14 Correct 113 ms 6908 KB Output is correct
15 Correct 115 ms 6892 KB Output is correct
16 Correct 114 ms 7020 KB Output is correct
17 Correct 116 ms 6892 KB Output is correct
18 Correct 106 ms 6892 KB Output is correct
19 Correct 108 ms 6892 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 124 ms 7148 KB Output is correct
22 Correct 126 ms 7148 KB Output is correct
23 Correct 127 ms 7148 KB Output is correct
24 Correct 128 ms 7148 KB Output is correct
25 Correct 128 ms 7152 KB Output is correct
26 Correct 128 ms 7340 KB Output is correct
27 Correct 126 ms 7148 KB Output is correct
28 Correct 96 ms 7148 KB Output is correct
29 Correct 97 ms 7148 KB Output is correct
30 Correct 1 ms 364 KB Output is correct
31 Incorrect 1 ms 364 KB Output isn't correct
32 Halted 0 ms 0 KB -