Submission #329148

# Submission time Handle Problem Language Result Execution time Memory
329148 2020-11-19T13:46:59 Z poom2904 Mountains (NOI20_mountains) C++11
66 / 100
110 ms 10988 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<int> lower_l(300001,0);
vector<int> 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,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;
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6252 KB Output is correct
2 Correct 110 ms 10988 KB Output is correct
3 Correct 104 ms 10860 KB Output is correct
4 Correct 104 ms 10860 KB Output is correct
5 Correct 105 ms 10860 KB Output is correct
6 Correct 104 ms 10860 KB Output is correct
7 Correct 107 ms 10988 KB Output is correct
8 Correct 104 ms 10860 KB Output is correct
9 Correct 108 ms 10988 KB Output is correct
10 Correct 105 ms 10860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 10860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 10860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6252 KB Output is correct
2 Correct 7 ms 6252 KB Output is correct
3 Correct 5 ms 6252 KB Output is correct
4 Correct 5 ms 6252 KB Output is correct
5 Correct 5 ms 6252 KB Output is correct
6 Correct 4 ms 6252 KB Output is correct
7 Correct 5 ms 6252 KB Output is correct
8 Correct 4 ms 6252 KB Output is correct
9 Correct 5 ms 6252 KB Output is correct
10 Correct 4 ms 6252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6252 KB Output is correct
2 Correct 7 ms 6252 KB Output is correct
3 Correct 5 ms 6252 KB Output is correct
4 Correct 5 ms 6252 KB Output is correct
5 Correct 5 ms 6252 KB Output is correct
6 Correct 4 ms 6252 KB Output is correct
7 Correct 5 ms 6252 KB Output is correct
8 Correct 4 ms 6252 KB Output is correct
9 Correct 5 ms 6252 KB Output is correct
10 Correct 4 ms 6252 KB Output is correct
11 Correct 9 ms 6380 KB Output is correct
12 Correct 8 ms 6380 KB Output is correct
13 Correct 8 ms 6380 KB Output is correct
14 Correct 8 ms 6380 KB Output is correct
15 Correct 10 ms 6380 KB Output is correct
16 Correct 8 ms 6380 KB Output is correct
17 Correct 8 ms 6380 KB Output is correct
18 Correct 8 ms 6380 KB Output is correct
19 Correct 7 ms 6380 KB Output is correct
20 Correct 4 ms 6252 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 10860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 6252 KB Output is correct
2 Correct 110 ms 10988 KB Output is correct
3 Correct 104 ms 10860 KB Output is correct
4 Correct 104 ms 10860 KB Output is correct
5 Correct 105 ms 10860 KB Output is correct
6 Correct 104 ms 10860 KB Output is correct
7 Correct 107 ms 10988 KB Output is correct
8 Correct 104 ms 10860 KB Output is correct
9 Correct 108 ms 10988 KB Output is correct
10 Correct 105 ms 10860 KB Output is correct
11 Incorrect 73 ms 10860 KB Output isn't correct
12 Halted 0 ms 0 KB -