답안 #329146

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
329146 2020-11-19T13:37:23 Z poom2904 Mountains (NOI20_mountains) C++11
66 / 100
111 ms 15340 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<int> fen(300001);
void upd(int idx)
{
    for(;idx<=300000;idx+=idx&-idx)fen[idx]++;
}
int read(int idx)
{
    int 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 4 ms 4972 KB Output is correct
2 Correct 104 ms 9708 KB Output is correct
3 Correct 108 ms 15340 KB Output is correct
4 Correct 108 ms 15212 KB Output is correct
5 Correct 107 ms 15212 KB Output is correct
6 Correct 111 ms 15212 KB Output is correct
7 Correct 107 ms 15340 KB Output is correct
8 Correct 108 ms 15340 KB Output is correct
9 Correct 106 ms 15340 KB Output is correct
10 Correct 108 ms 15340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 9836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 9836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5100 KB Output is correct
2 Correct 5 ms 5100 KB Output is correct
3 Correct 4 ms 4972 KB Output is correct
4 Correct 4 ms 4972 KB Output is correct
5 Correct 5 ms 4972 KB Output is correct
6 Correct 4 ms 4972 KB Output is correct
7 Correct 4 ms 4972 KB Output is correct
8 Correct 5 ms 4972 KB Output is correct
9 Correct 4 ms 4972 KB Output is correct
10 Correct 4 ms 4972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5100 KB Output is correct
2 Correct 5 ms 5100 KB Output is correct
3 Correct 4 ms 4972 KB Output is correct
4 Correct 4 ms 4972 KB Output is correct
5 Correct 5 ms 4972 KB Output is correct
6 Correct 4 ms 4972 KB Output is correct
7 Correct 4 ms 4972 KB Output is correct
8 Correct 5 ms 4972 KB Output is correct
9 Correct 4 ms 4972 KB Output is correct
10 Correct 4 ms 4972 KB Output is correct
11 Correct 8 ms 5228 KB Output is correct
12 Correct 9 ms 5228 KB Output is correct
13 Correct 8 ms 5228 KB Output is correct
14 Correct 8 ms 5228 KB Output is correct
15 Correct 8 ms 5228 KB Output is correct
16 Correct 8 ms 5228 KB Output is correct
17 Correct 8 ms 5228 KB Output is correct
18 Correct 8 ms 5228 KB Output is correct
19 Correct 9 ms 5228 KB Output is correct
20 Correct 4 ms 4972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 9836 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 4972 KB Output is correct
2 Correct 104 ms 9708 KB Output is correct
3 Correct 108 ms 15340 KB Output is correct
4 Correct 108 ms 15212 KB Output is correct
5 Correct 107 ms 15212 KB Output is correct
6 Correct 111 ms 15212 KB Output is correct
7 Correct 107 ms 15340 KB Output is correct
8 Correct 108 ms 15340 KB Output is correct
9 Correct 106 ms 15340 KB Output is correct
10 Correct 108 ms 15340 KB Output is correct
11 Incorrect 69 ms 9836 KB Output isn't correct
12 Halted 0 ms 0 KB -