답안 #874853

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
874853 2023-11-18T01:12:07 Z 12345678 Mountains (NOI20_mountains) C++17
100 / 100
170 ms 19400 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long

const int nx=3e5+5;
ll n, h[nx], t, dp[nx], res;
vector<ll> v;

struct fenwick
{
    ll d[nx];
    void add(int idx)
    {
        for (int i=idx; i<nx; i+=(i&-i)) d[i]++;
    }
    ll query(int idx)
    {
        ll res=0;
        for (int i=idx; i>0; i-=(i&-i)) res+=d[i];
        return res;
    }
} l, r;

int main()
{
    cin.tie(NULL)->sync_with_stdio(false);
    cin>>n;
    for (int i=1; i<=n; i++) cin>>h[i], v.push_back(h[i]);
    sort(v.begin(), v.end());
    for (int i=1; i<=n; i++)
    {
        int idx=lower_bound(v.begin(), v.end(), h[i])-v.begin()+1;
        dp[i]=l.query(idx-1);
        l.add(idx);
    }
    for (int i=n; i>=1; i--)
    {
        int idx=lower_bound(v.begin(), v.end(), h[i])-v.begin()+1;
        res+=dp[i]*r.query(idx-1);
        r.add(idx);
    }
    cout<<res;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 86 ms 19000 KB Output is correct
3 Correct 84 ms 18360 KB Output is correct
4 Correct 84 ms 17644 KB Output is correct
5 Correct 84 ms 18160 KB Output is correct
6 Correct 84 ms 18872 KB Output is correct
7 Correct 84 ms 18372 KB Output is correct
8 Correct 86 ms 18880 KB Output is correct
9 Correct 81 ms 18900 KB Output is correct
10 Correct 81 ms 19400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 11216 KB Output is correct
2 Correct 42 ms 11220 KB Output is correct
3 Correct 47 ms 10376 KB Output is correct
4 Correct 42 ms 10448 KB Output is correct
5 Correct 41 ms 11728 KB Output is correct
6 Correct 43 ms 10688 KB Output is correct
7 Correct 43 ms 11972 KB Output is correct
8 Correct 39 ms 11848 KB Output is correct
9 Correct 39 ms 10700 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 11216 KB Output is correct
2 Correct 42 ms 11220 KB Output is correct
3 Correct 47 ms 10376 KB Output is correct
4 Correct 42 ms 10448 KB Output is correct
5 Correct 41 ms 11728 KB Output is correct
6 Correct 43 ms 10688 KB Output is correct
7 Correct 43 ms 11972 KB Output is correct
8 Correct 39 ms 11848 KB Output is correct
9 Correct 39 ms 10700 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 86 ms 12996 KB Output is correct
12 Correct 90 ms 11820 KB Output is correct
13 Correct 90 ms 12488 KB Output is correct
14 Correct 89 ms 12484 KB Output is correct
15 Correct 87 ms 10684 KB Output is correct
16 Correct 86 ms 11976 KB Output is correct
17 Correct 89 ms 11964 KB Output is correct
18 Correct 38 ms 12224 KB Output is correct
19 Correct 37 ms 12496 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 6492 KB Output is correct
2 Correct 1 ms 6492 KB Output is correct
3 Correct 1 ms 6492 KB Output is correct
4 Correct 1 ms 6492 KB Output is correct
5 Correct 1 ms 6492 KB Output is correct
6 Correct 1 ms 6492 KB Output is correct
7 Correct 1 ms 6492 KB Output is correct
8 Correct 1 ms 6492 KB Output is correct
9 Correct 1 ms 6492 KB Output is correct
10 Correct 1 ms 6492 KB Output is correct
11 Correct 5 ms 7084 KB Output is correct
12 Correct 5 ms 7004 KB Output is correct
13 Correct 5 ms 7000 KB Output is correct
14 Correct 5 ms 7004 KB Output is correct
15 Correct 5 ms 7004 KB Output is correct
16 Correct 5 ms 7000 KB Output is correct
17 Correct 5 ms 7004 KB Output is correct
18 Correct 5 ms 7016 KB Output is correct
19 Correct 4 ms 7004 KB Output is correct
20 Correct 1 ms 8540 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 40 ms 11216 KB Output is correct
2 Correct 42 ms 11220 KB Output is correct
3 Correct 47 ms 10376 KB Output is correct
4 Correct 42 ms 10448 KB Output is correct
5 Correct 41 ms 11728 KB Output is correct
6 Correct 43 ms 10688 KB Output is correct
7 Correct 43 ms 11972 KB Output is correct
8 Correct 39 ms 11848 KB Output is correct
9 Correct 39 ms 10700 KB Output is correct
10 Correct 1 ms 8540 KB Output is correct
11 Correct 86 ms 12996 KB Output is correct
12 Correct 90 ms 11820 KB Output is correct
13 Correct 90 ms 12488 KB Output is correct
14 Correct 89 ms 12484 KB Output is correct
15 Correct 87 ms 10684 KB Output is correct
16 Correct 86 ms 11976 KB Output is correct
17 Correct 89 ms 11964 KB Output is correct
18 Correct 38 ms 12224 KB Output is correct
19 Correct 37 ms 12496 KB Output is correct
20 Correct 1 ms 6492 KB Output is correct
21 Correct 143 ms 14012 KB Output is correct
22 Correct 148 ms 15556 KB Output is correct
23 Correct 145 ms 15400 KB Output is correct
24 Correct 146 ms 14252 KB Output is correct
25 Correct 145 ms 14012 KB Output is correct
26 Correct 144 ms 14460 KB Output is correct
27 Correct 144 ms 14356 KB Output is correct
28 Correct 60 ms 15292 KB Output is correct
29 Correct 60 ms 14524 KB Output is correct
30 Correct 1 ms 6488 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 8536 KB Output is correct
2 Correct 86 ms 19000 KB Output is correct
3 Correct 84 ms 18360 KB Output is correct
4 Correct 84 ms 17644 KB Output is correct
5 Correct 84 ms 18160 KB Output is correct
6 Correct 84 ms 18872 KB Output is correct
7 Correct 84 ms 18372 KB Output is correct
8 Correct 86 ms 18880 KB Output is correct
9 Correct 81 ms 18900 KB Output is correct
10 Correct 81 ms 19400 KB Output is correct
11 Correct 40 ms 11216 KB Output is correct
12 Correct 42 ms 11220 KB Output is correct
13 Correct 47 ms 10376 KB Output is correct
14 Correct 42 ms 10448 KB Output is correct
15 Correct 41 ms 11728 KB Output is correct
16 Correct 43 ms 10688 KB Output is correct
17 Correct 43 ms 11972 KB Output is correct
18 Correct 39 ms 11848 KB Output is correct
19 Correct 39 ms 10700 KB Output is correct
20 Correct 1 ms 8540 KB Output is correct
21 Correct 86 ms 12996 KB Output is correct
22 Correct 90 ms 11820 KB Output is correct
23 Correct 90 ms 12488 KB Output is correct
24 Correct 89 ms 12484 KB Output is correct
25 Correct 87 ms 10684 KB Output is correct
26 Correct 86 ms 11976 KB Output is correct
27 Correct 89 ms 11964 KB Output is correct
28 Correct 38 ms 12224 KB Output is correct
29 Correct 37 ms 12496 KB Output is correct
30 Correct 1 ms 6492 KB Output is correct
31 Correct 1 ms 6492 KB Output is correct
32 Correct 1 ms 6492 KB Output is correct
33 Correct 1 ms 6492 KB Output is correct
34 Correct 1 ms 6492 KB Output is correct
35 Correct 1 ms 6492 KB Output is correct
36 Correct 1 ms 6492 KB Output is correct
37 Correct 1 ms 6492 KB Output is correct
38 Correct 1 ms 6492 KB Output is correct
39 Correct 1 ms 6492 KB Output is correct
40 Correct 1 ms 6492 KB Output is correct
41 Correct 5 ms 7084 KB Output is correct
42 Correct 5 ms 7004 KB Output is correct
43 Correct 5 ms 7000 KB Output is correct
44 Correct 5 ms 7004 KB Output is correct
45 Correct 5 ms 7004 KB Output is correct
46 Correct 5 ms 7000 KB Output is correct
47 Correct 5 ms 7004 KB Output is correct
48 Correct 5 ms 7016 KB Output is correct
49 Correct 4 ms 7004 KB Output is correct
50 Correct 1 ms 8540 KB Output is correct
51 Correct 143 ms 14012 KB Output is correct
52 Correct 148 ms 15556 KB Output is correct
53 Correct 145 ms 15400 KB Output is correct
54 Correct 146 ms 14252 KB Output is correct
55 Correct 145 ms 14012 KB Output is correct
56 Correct 144 ms 14460 KB Output is correct
57 Correct 144 ms 14356 KB Output is correct
58 Correct 60 ms 15292 KB Output is correct
59 Correct 60 ms 14524 KB Output is correct
60 Correct 1 ms 6488 KB Output is correct
61 Correct 160 ms 19164 KB Output is correct
62 Correct 161 ms 17864 KB Output is correct
63 Correct 161 ms 19376 KB Output is correct
64 Correct 160 ms 18900 KB Output is correct
65 Correct 164 ms 19332 KB Output is correct
66 Correct 160 ms 18880 KB Output is correct
67 Correct 159 ms 19308 KB Output is correct
68 Correct 170 ms 19336 KB Output is correct
69 Correct 146 ms 14780 KB Output is correct
70 Correct 1 ms 8792 KB Output is correct