Submission #329151

# Submission time Handle Problem Language Result Execution time Memory
329151 2020-11-19T13:49:18 Z poom2904 Mountains (NOI20_mountains) C++11
100 / 100
149 ms 13548 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int n;
bool cmp(const pair<ll,int> a,const pair<ll,int> b)
{
    return a.first<b.first;
}
vector<int> new_hei(300001,0);
vector<ll> lower_l(300001,0);
vector<ll> lower_r(300001,0);
vector<ll> fen(300001);
void upd(int idx)
{
    for(;idx<=300000;idx+=idx&-idx)fen[idx]++;
}
ll read(int 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,int> > 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;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8556 KB Output is correct
2 Correct 105 ms 13420 KB Output is correct
3 Correct 108 ms 13292 KB Output is correct
4 Correct 119 ms 13420 KB Output is correct
5 Correct 110 ms 13420 KB Output is correct
6 Correct 106 ms 13420 KB Output is correct
7 Correct 109 ms 13420 KB Output is correct
8 Correct 105 ms 13292 KB Output is correct
9 Correct 110 ms 13292 KB Output is correct
10 Correct 107 ms 13548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 13292 KB Output is correct
2 Correct 79 ms 13420 KB Output is correct
3 Correct 79 ms 13292 KB Output is correct
4 Correct 77 ms 13292 KB Output is correct
5 Correct 76 ms 13420 KB Output is correct
6 Correct 77 ms 13292 KB Output is correct
7 Correct 77 ms 13420 KB Output is correct
8 Correct 75 ms 13420 KB Output is correct
9 Correct 74 ms 13420 KB Output is correct
10 Correct 5 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 13292 KB Output is correct
2 Correct 79 ms 13420 KB Output is correct
3 Correct 79 ms 13292 KB Output is correct
4 Correct 77 ms 13292 KB Output is correct
5 Correct 76 ms 13420 KB Output is correct
6 Correct 77 ms 13292 KB Output is correct
7 Correct 77 ms 13420 KB Output is correct
8 Correct 75 ms 13420 KB Output is correct
9 Correct 74 ms 13420 KB Output is correct
10 Correct 5 ms 8556 KB Output is correct
11 Correct 81 ms 13292 KB Output is correct
12 Correct 81 ms 13292 KB Output is correct
13 Correct 80 ms 13420 KB Output is correct
14 Correct 81 ms 13292 KB Output is correct
15 Correct 84 ms 13292 KB Output is correct
16 Correct 81 ms 13292 KB Output is correct
17 Correct 81 ms 13420 KB Output is correct
18 Correct 70 ms 13420 KB Output is correct
19 Correct 69 ms 13292 KB Output is correct
20 Correct 6 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8556 KB Output is correct
2 Correct 5 ms 8556 KB Output is correct
3 Correct 5 ms 8556 KB Output is correct
4 Correct 5 ms 8556 KB Output is correct
5 Correct 6 ms 8556 KB Output is correct
6 Correct 6 ms 8556 KB Output is correct
7 Correct 5 ms 8556 KB Output is correct
8 Correct 6 ms 8556 KB Output is correct
9 Correct 5 ms 8556 KB Output is correct
10 Correct 6 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8556 KB Output is correct
2 Correct 5 ms 8556 KB Output is correct
3 Correct 5 ms 8556 KB Output is correct
4 Correct 5 ms 8556 KB Output is correct
5 Correct 6 ms 8556 KB Output is correct
6 Correct 6 ms 8556 KB Output is correct
7 Correct 5 ms 8556 KB Output is correct
8 Correct 6 ms 8556 KB Output is correct
9 Correct 5 ms 8556 KB Output is correct
10 Correct 6 ms 8556 KB Output is correct
11 Correct 11 ms 8684 KB Output is correct
12 Correct 10 ms 8684 KB Output is correct
13 Correct 9 ms 8684 KB Output is correct
14 Correct 9 ms 8684 KB Output is correct
15 Correct 10 ms 8684 KB Output is correct
16 Correct 10 ms 8684 KB Output is correct
17 Correct 9 ms 8684 KB Output is correct
18 Correct 9 ms 8684 KB Output is correct
19 Correct 8 ms 8684 KB Output is correct
20 Correct 5 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 13292 KB Output is correct
2 Correct 79 ms 13420 KB Output is correct
3 Correct 79 ms 13292 KB Output is correct
4 Correct 77 ms 13292 KB Output is correct
5 Correct 76 ms 13420 KB Output is correct
6 Correct 77 ms 13292 KB Output is correct
7 Correct 77 ms 13420 KB Output is correct
8 Correct 75 ms 13420 KB Output is correct
9 Correct 74 ms 13420 KB Output is correct
10 Correct 5 ms 8556 KB Output is correct
11 Correct 81 ms 13292 KB Output is correct
12 Correct 81 ms 13292 KB Output is correct
13 Correct 80 ms 13420 KB Output is correct
14 Correct 81 ms 13292 KB Output is correct
15 Correct 84 ms 13292 KB Output is correct
16 Correct 81 ms 13292 KB Output is correct
17 Correct 81 ms 13420 KB Output is correct
18 Correct 70 ms 13420 KB Output is correct
19 Correct 69 ms 13292 KB Output is correct
20 Correct 6 ms 8556 KB Output is correct
21 Correct 103 ms 13292 KB Output is correct
22 Correct 103 ms 13292 KB Output is correct
23 Correct 108 ms 13420 KB Output is correct
24 Correct 103 ms 13292 KB Output is correct
25 Correct 104 ms 13420 KB Output is correct
26 Correct 103 ms 13292 KB Output is correct
27 Correct 103 ms 13420 KB Output is correct
28 Correct 75 ms 13292 KB Output is correct
29 Correct 75 ms 13292 KB Output is correct
30 Correct 6 ms 8556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 8556 KB Output is correct
2 Correct 105 ms 13420 KB Output is correct
3 Correct 108 ms 13292 KB Output is correct
4 Correct 119 ms 13420 KB Output is correct
5 Correct 110 ms 13420 KB Output is correct
6 Correct 106 ms 13420 KB Output is correct
7 Correct 109 ms 13420 KB Output is correct
8 Correct 105 ms 13292 KB Output is correct
9 Correct 110 ms 13292 KB Output is correct
10 Correct 107 ms 13548 KB Output is correct
11 Correct 76 ms 13292 KB Output is correct
12 Correct 79 ms 13420 KB Output is correct
13 Correct 79 ms 13292 KB Output is correct
14 Correct 77 ms 13292 KB Output is correct
15 Correct 76 ms 13420 KB Output is correct
16 Correct 77 ms 13292 KB Output is correct
17 Correct 77 ms 13420 KB Output is correct
18 Correct 75 ms 13420 KB Output is correct
19 Correct 74 ms 13420 KB Output is correct
20 Correct 5 ms 8556 KB Output is correct
21 Correct 81 ms 13292 KB Output is correct
22 Correct 81 ms 13292 KB Output is correct
23 Correct 80 ms 13420 KB Output is correct
24 Correct 81 ms 13292 KB Output is correct
25 Correct 84 ms 13292 KB Output is correct
26 Correct 81 ms 13292 KB Output is correct
27 Correct 81 ms 13420 KB Output is correct
28 Correct 70 ms 13420 KB Output is correct
29 Correct 69 ms 13292 KB Output is correct
30 Correct 6 ms 8556 KB Output is correct
31 Correct 5 ms 8556 KB Output is correct
32 Correct 5 ms 8556 KB Output is correct
33 Correct 5 ms 8556 KB Output is correct
34 Correct 5 ms 8556 KB Output is correct
35 Correct 6 ms 8556 KB Output is correct
36 Correct 6 ms 8556 KB Output is correct
37 Correct 5 ms 8556 KB Output is correct
38 Correct 6 ms 8556 KB Output is correct
39 Correct 5 ms 8556 KB Output is correct
40 Correct 6 ms 8556 KB Output is correct
41 Correct 11 ms 8684 KB Output is correct
42 Correct 10 ms 8684 KB Output is correct
43 Correct 9 ms 8684 KB Output is correct
44 Correct 9 ms 8684 KB Output is correct
45 Correct 10 ms 8684 KB Output is correct
46 Correct 10 ms 8684 KB Output is correct
47 Correct 9 ms 8684 KB Output is correct
48 Correct 9 ms 8684 KB Output is correct
49 Correct 8 ms 8684 KB Output is correct
50 Correct 5 ms 8556 KB Output is correct
51 Correct 103 ms 13292 KB Output is correct
52 Correct 103 ms 13292 KB Output is correct
53 Correct 108 ms 13420 KB Output is correct
54 Correct 103 ms 13292 KB Output is correct
55 Correct 104 ms 13420 KB Output is correct
56 Correct 103 ms 13292 KB Output is correct
57 Correct 103 ms 13420 KB Output is correct
58 Correct 75 ms 13292 KB Output is correct
59 Correct 75 ms 13292 KB Output is correct
60 Correct 6 ms 8556 KB Output is correct
61 Correct 134 ms 13292 KB Output is correct
62 Correct 132 ms 13292 KB Output is correct
63 Correct 138 ms 13292 KB Output is correct
64 Correct 135 ms 13420 KB Output is correct
65 Correct 135 ms 13292 KB Output is correct
66 Correct 139 ms 13292 KB Output is correct
67 Correct 149 ms 13420 KB Output is correct
68 Correct 132 ms 13292 KB Output is correct
69 Correct 104 ms 13292 KB Output is correct
70 Correct 5 ms 8556 KB Output is correct