답안 #337662

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
337662 2020-12-21T11:20:52 Z Vladth11 Mountains (NOI20_mountains) C++14
24 / 100
147 ms 6636 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 * (1LL * st[i] * 1LL * 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 88 ms 6252 KB Output is correct
4 Correct 89 ms 6252 KB Output is correct
5 Correct 91 ms 6252 KB Output is correct
6 Correct 90 ms 6232 KB Output is correct
7 Correct 89 ms 6252 KB Output is correct
8 Correct 88 ms 6284 KB Output is correct
9 Correct 88 ms 6256 KB Output is correct
10 Correct 88 ms 6252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 6252 KB Output is correct
2 Correct 115 ms 6232 KB Output is correct
3 Correct 115 ms 6252 KB Output is correct
4 Correct 114 ms 6252 KB Output is correct
5 Correct 114 ms 6252 KB Output is correct
6 Correct 112 ms 6252 KB Output is correct
7 Correct 113 ms 6252 KB Output is correct
8 Correct 106 ms 6252 KB Output is correct
9 Correct 112 ms 6252 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 113 ms 6252 KB Output is correct
2 Correct 115 ms 6232 KB Output is correct
3 Correct 115 ms 6252 KB Output is correct
4 Correct 114 ms 6252 KB Output is correct
5 Correct 114 ms 6252 KB Output is correct
6 Correct 112 ms 6252 KB Output is correct
7 Correct 113 ms 6252 KB Output is correct
8 Correct 106 ms 6252 KB Output is correct
9 Correct 112 ms 6252 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 127 ms 6232 KB Output is correct
12 Correct 125 ms 6252 KB Output is correct
13 Correct 125 ms 6252 KB Output is correct
14 Correct 126 ms 6336 KB Output is correct
15 Correct 126 ms 6252 KB Output is correct
16 Correct 124 ms 6232 KB Output is correct
17 Correct 127 ms 6252 KB Output is correct
18 Correct 96 ms 6252 KB Output is correct
19 Correct 102 ms 6252 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 113 ms 6252 KB Output is correct
2 Correct 115 ms 6232 KB Output is correct
3 Correct 115 ms 6252 KB Output is correct
4 Correct 114 ms 6252 KB Output is correct
5 Correct 114 ms 6252 KB Output is correct
6 Correct 112 ms 6252 KB Output is correct
7 Correct 113 ms 6252 KB Output is correct
8 Correct 106 ms 6252 KB Output is correct
9 Correct 112 ms 6252 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 127 ms 6232 KB Output is correct
12 Correct 125 ms 6252 KB Output is correct
13 Correct 125 ms 6252 KB Output is correct
14 Correct 126 ms 6336 KB Output is correct
15 Correct 126 ms 6252 KB Output is correct
16 Correct 124 ms 6232 KB Output is correct
17 Correct 127 ms 6252 KB Output is correct
18 Correct 96 ms 6252 KB Output is correct
19 Correct 102 ms 6252 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 140 ms 6636 KB Output is correct
22 Correct 140 ms 6636 KB Output is correct
23 Correct 137 ms 6636 KB Output is correct
24 Correct 139 ms 6636 KB Output is correct
25 Correct 147 ms 6636 KB Output is correct
26 Correct 141 ms 6592 KB Output is correct
27 Correct 140 ms 6636 KB Output is correct
28 Correct 105 ms 6572 KB Output is correct
29 Correct 98 ms 6636 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 88 ms 6252 KB Output is correct
4 Correct 89 ms 6252 KB Output is correct
5 Correct 91 ms 6252 KB Output is correct
6 Correct 90 ms 6232 KB Output is correct
7 Correct 89 ms 6252 KB Output is correct
8 Correct 88 ms 6284 KB Output is correct
9 Correct 88 ms 6256 KB Output is correct
10 Correct 88 ms 6252 KB Output is correct
11 Correct 113 ms 6252 KB Output is correct
12 Correct 115 ms 6232 KB Output is correct
13 Correct 115 ms 6252 KB Output is correct
14 Correct 114 ms 6252 KB Output is correct
15 Correct 114 ms 6252 KB Output is correct
16 Correct 112 ms 6252 KB Output is correct
17 Correct 113 ms 6252 KB Output is correct
18 Correct 106 ms 6252 KB Output is correct
19 Correct 112 ms 6252 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 127 ms 6232 KB Output is correct
22 Correct 125 ms 6252 KB Output is correct
23 Correct 125 ms 6252 KB Output is correct
24 Correct 126 ms 6336 KB Output is correct
25 Correct 126 ms 6252 KB Output is correct
26 Correct 124 ms 6232 KB Output is correct
27 Correct 127 ms 6252 KB Output is correct
28 Correct 96 ms 6252 KB Output is correct
29 Correct 102 ms 6252 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 -