답안 #329147

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329147 2020-11-19T13:45:01 Z poom2904 Mountains (NOI20_mountains) C++11
100 / 100
139 ms 20332 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int n;
bool cmp(const pair<ll,ll> a,const pair<ll,ll> b)
{
    return a.first<b.first;
}
vector<ll> new_hei(300001,0);
vector<ll> lower_l(300001,0);
vector<ll> lower_r(300001,0);
vector<ll> fen(300001);
void upd(ll idx)
{
    for(;idx<=300000;idx+=idx&-idx)fen[idx]++;
}
ll read(ll idx)
{
    ll res=0;
    for(;idx>0;idx-=idx&-idx)res+=fen[idx];
    return res;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    cin>>n;
    vector<pair<ll,ll> > height(n);
    for(int i=0;i<n;i++){cin>>height[i].first;height[i].second=i+1;}
    sort(height.begin(),height.end(),cmp);
    ll pre=-1,new_h=0;
    for(int i=0;i<n;)
    {
        if(height[i].first!=pre)
        {
            new_h++;
            pre=height[i].first;
        }
        new_hei[height[i++].second]=new_h;
    }
    fill(fen.begin(),fen.end(),0);
    for(int i=2;i<=n;i++)
    {
        upd(new_hei[i-1]);
        lower_l[i]=read(new_hei[i]-1);
    }
    fill(fen.begin(),fen.end(),0);
    for(int i=n-1;i>=1;i--)
    {
        upd(new_hei[i+1]);
        lower_r[i]=read(new_hei[i]-1);
    }
    ll res=0;
    for(int i=1;i<=n;i++)res+=lower_l[i]*lower_r[i];
    cout<<res;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9708 KB Output is correct
2 Correct 110 ms 14444 KB Output is correct
3 Correct 108 ms 14444 KB Output is correct
4 Correct 109 ms 14572 KB Output is correct
5 Correct 110 ms 14572 KB Output is correct
6 Correct 109 ms 14444 KB Output is correct
7 Correct 108 ms 14444 KB Output is correct
8 Correct 109 ms 14444 KB Output is correct
9 Correct 109 ms 14444 KB Output is correct
10 Correct 109 ms 14444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 14444 KB Output is correct
2 Correct 82 ms 15212 KB Output is correct
3 Correct 80 ms 15084 KB Output is correct
4 Correct 81 ms 15212 KB Output is correct
5 Correct 80 ms 15084 KB Output is correct
6 Correct 81 ms 15084 KB Output is correct
7 Correct 79 ms 15104 KB Output is correct
8 Correct 78 ms 15084 KB Output is correct
9 Correct 77 ms 15084 KB Output is correct
10 Correct 6 ms 9708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 14444 KB Output is correct
2 Correct 82 ms 15212 KB Output is correct
3 Correct 80 ms 15084 KB Output is correct
4 Correct 81 ms 15212 KB Output is correct
5 Correct 80 ms 15084 KB Output is correct
6 Correct 81 ms 15084 KB Output is correct
7 Correct 79 ms 15104 KB Output is correct
8 Correct 78 ms 15084 KB Output is correct
9 Correct 77 ms 15084 KB Output is correct
10 Correct 6 ms 9708 KB Output is correct
11 Correct 87 ms 15340 KB Output is correct
12 Correct 82 ms 15340 KB Output is correct
13 Correct 84 ms 15468 KB Output is correct
14 Correct 82 ms 15340 KB Output is correct
15 Correct 83 ms 15340 KB Output is correct
16 Correct 83 ms 15468 KB Output is correct
17 Correct 83 ms 15340 KB Output is correct
18 Correct 72 ms 15340 KB Output is correct
19 Correct 71 ms 15340 KB Output is correct
20 Correct 6 ms 9708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9708 KB Output is correct
2 Correct 6 ms 9708 KB Output is correct
3 Correct 6 ms 9708 KB Output is correct
4 Correct 6 ms 9708 KB Output is correct
5 Correct 7 ms 9708 KB Output is correct
6 Correct 7 ms 9708 KB Output is correct
7 Correct 8 ms 9708 KB Output is correct
8 Correct 6 ms 9708 KB Output is correct
9 Correct 6 ms 9708 KB Output is correct
10 Correct 6 ms 9708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 9708 KB Output is correct
2 Correct 6 ms 9708 KB Output is correct
3 Correct 6 ms 9708 KB Output is correct
4 Correct 6 ms 9708 KB Output is correct
5 Correct 7 ms 9708 KB Output is correct
6 Correct 7 ms 9708 KB Output is correct
7 Correct 8 ms 9708 KB Output is correct
8 Correct 6 ms 9708 KB Output is correct
9 Correct 6 ms 9708 KB Output is correct
10 Correct 6 ms 9708 KB Output is correct
11 Correct 10 ms 9836 KB Output is correct
12 Correct 10 ms 9836 KB Output is correct
13 Correct 10 ms 9836 KB Output is correct
14 Correct 10 ms 9836 KB Output is correct
15 Correct 10 ms 9836 KB Output is correct
16 Correct 11 ms 9964 KB Output is correct
17 Correct 10 ms 9836 KB Output is correct
18 Correct 10 ms 9836 KB Output is correct
19 Correct 9 ms 9836 KB Output is correct
20 Correct 6 ms 9708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 14444 KB Output is correct
2 Correct 82 ms 15212 KB Output is correct
3 Correct 80 ms 15084 KB Output is correct
4 Correct 81 ms 15212 KB Output is correct
5 Correct 80 ms 15084 KB Output is correct
6 Correct 81 ms 15084 KB Output is correct
7 Correct 79 ms 15104 KB Output is correct
8 Correct 78 ms 15084 KB Output is correct
9 Correct 77 ms 15084 KB Output is correct
10 Correct 6 ms 9708 KB Output is correct
11 Correct 87 ms 15340 KB Output is correct
12 Correct 82 ms 15340 KB Output is correct
13 Correct 84 ms 15468 KB Output is correct
14 Correct 82 ms 15340 KB Output is correct
15 Correct 83 ms 15340 KB Output is correct
16 Correct 83 ms 15468 KB Output is correct
17 Correct 83 ms 15340 KB Output is correct
18 Correct 72 ms 15340 KB Output is correct
19 Correct 71 ms 15340 KB Output is correct
20 Correct 6 ms 9708 KB Output is correct
21 Correct 105 ms 16236 KB Output is correct
22 Correct 108 ms 16364 KB Output is correct
23 Correct 103 ms 16236 KB Output is correct
24 Correct 103 ms 16236 KB Output is correct
25 Correct 108 ms 16236 KB Output is correct
26 Correct 104 ms 16108 KB Output is correct
27 Correct 107 ms 16108 KB Output is correct
28 Correct 79 ms 16108 KB Output is correct
29 Correct 81 ms 16236 KB Output is correct
30 Correct 6 ms 9708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 9708 KB Output is correct
2 Correct 110 ms 14444 KB Output is correct
3 Correct 108 ms 14444 KB Output is correct
4 Correct 109 ms 14572 KB Output is correct
5 Correct 110 ms 14572 KB Output is correct
6 Correct 109 ms 14444 KB Output is correct
7 Correct 108 ms 14444 KB Output is correct
8 Correct 109 ms 14444 KB Output is correct
9 Correct 109 ms 14444 KB Output is correct
10 Correct 109 ms 14444 KB Output is correct
11 Correct 79 ms 14444 KB Output is correct
12 Correct 82 ms 15212 KB Output is correct
13 Correct 80 ms 15084 KB Output is correct
14 Correct 81 ms 15212 KB Output is correct
15 Correct 80 ms 15084 KB Output is correct
16 Correct 81 ms 15084 KB Output is correct
17 Correct 79 ms 15104 KB Output is correct
18 Correct 78 ms 15084 KB Output is correct
19 Correct 77 ms 15084 KB Output is correct
20 Correct 6 ms 9708 KB Output is correct
21 Correct 87 ms 15340 KB Output is correct
22 Correct 82 ms 15340 KB Output is correct
23 Correct 84 ms 15468 KB Output is correct
24 Correct 82 ms 15340 KB Output is correct
25 Correct 83 ms 15340 KB Output is correct
26 Correct 83 ms 15468 KB Output is correct
27 Correct 83 ms 15340 KB Output is correct
28 Correct 72 ms 15340 KB Output is correct
29 Correct 71 ms 15340 KB Output is correct
30 Correct 6 ms 9708 KB Output is correct
31 Correct 8 ms 9708 KB Output is correct
32 Correct 6 ms 9708 KB Output is correct
33 Correct 6 ms 9708 KB Output is correct
34 Correct 6 ms 9708 KB Output is correct
35 Correct 7 ms 9708 KB Output is correct
36 Correct 7 ms 9708 KB Output is correct
37 Correct 8 ms 9708 KB Output is correct
38 Correct 6 ms 9708 KB Output is correct
39 Correct 6 ms 9708 KB Output is correct
40 Correct 6 ms 9708 KB Output is correct
41 Correct 10 ms 9836 KB Output is correct
42 Correct 10 ms 9836 KB Output is correct
43 Correct 10 ms 9836 KB Output is correct
44 Correct 10 ms 9836 KB Output is correct
45 Correct 10 ms 9836 KB Output is correct
46 Correct 11 ms 9964 KB Output is correct
47 Correct 10 ms 9836 KB Output is correct
48 Correct 10 ms 9836 KB Output is correct
49 Correct 9 ms 9836 KB Output is correct
50 Correct 6 ms 9708 KB Output is correct
51 Correct 105 ms 16236 KB Output is correct
52 Correct 108 ms 16364 KB Output is correct
53 Correct 103 ms 16236 KB Output is correct
54 Correct 103 ms 16236 KB Output is correct
55 Correct 108 ms 16236 KB Output is correct
56 Correct 104 ms 16108 KB Output is correct
57 Correct 107 ms 16108 KB Output is correct
58 Correct 79 ms 16108 KB Output is correct
59 Correct 81 ms 16236 KB Output is correct
60 Correct 6 ms 9708 KB Output is correct
61 Correct 139 ms 19948 KB Output is correct
62 Correct 138 ms 20076 KB Output is correct
63 Correct 136 ms 20076 KB Output is correct
64 Correct 134 ms 19948 KB Output is correct
65 Correct 139 ms 20076 KB Output is correct
66 Correct 135 ms 19948 KB Output is correct
67 Correct 136 ms 19948 KB Output is correct
68 Correct 136 ms 20332 KB Output is correct
69 Correct 106 ms 16236 KB Output is correct
70 Correct 6 ms 9708 KB Output is correct