답안 #329150

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329150 2020-11-19T13:48:28 Z poom2904 Mountains (NOI20_mountains) C++11
66 / 100
112 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,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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6252 KB Output is correct
2 Correct 107 ms 10988 KB Output is correct
3 Correct 105 ms 10860 KB Output is correct
4 Correct 112 ms 10988 KB Output is correct
5 Correct 109 ms 10988 KB Output is correct
6 Correct 107 ms 10860 KB Output is correct
7 Correct 104 ms 10988 KB Output is correct
8 Correct 104 ms 10860 KB Output is correct
9 Correct 106 ms 10860 KB Output is correct
10 Correct 105 ms 10988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 10860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 10860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6252 KB Output is correct
2 Correct 4 ms 6252 KB Output is correct
3 Correct 5 ms 6252 KB Output is correct
4 Correct 4 ms 6252 KB Output is correct
5 Correct 5 ms 6252 KB Output is correct
6 Correct 5 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 4 ms 6252 KB Output is correct
10 Correct 4 ms 6252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6252 KB Output is correct
2 Correct 4 ms 6252 KB Output is correct
3 Correct 5 ms 6252 KB Output is correct
4 Correct 4 ms 6252 KB Output is correct
5 Correct 5 ms 6252 KB Output is correct
6 Correct 5 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 4 ms 6252 KB Output is correct
10 Correct 4 ms 6252 KB Output is correct
11 Correct 8 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 12 ms 6380 KB Output is correct
16 Correct 8 ms 6380 KB Output is correct
17 Correct 8 ms 6400 KB Output is correct
18 Correct 8 ms 6380 KB Output is correct
19 Correct 7 ms 6380 KB Output is correct
20 Correct 6 ms 6252 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 76 ms 10860 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 6252 KB Output is correct
2 Correct 107 ms 10988 KB Output is correct
3 Correct 105 ms 10860 KB Output is correct
4 Correct 112 ms 10988 KB Output is correct
5 Correct 109 ms 10988 KB Output is correct
6 Correct 107 ms 10860 KB Output is correct
7 Correct 104 ms 10988 KB Output is correct
8 Correct 104 ms 10860 KB Output is correct
9 Correct 106 ms 10860 KB Output is correct
10 Correct 105 ms 10988 KB Output is correct
11 Incorrect 76 ms 10860 KB Output isn't correct
12 Halted 0 ms 0 KB -