| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 285473 | keta_tsimakuridze | Mountains (NOI20_mountains) | C++14 | 557 ms | 14864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
long long tree[N],h[N],ans,b[N],k,i,bef,n,ind[N];
pair<long long,long long>a[N];
void update(int ind,int val){
for(ind;ind<=i;ind+=ind&(-ind)){
tree[ind]+=val;
}
}
int getans(int ind){
int pas=0;
for(ind;ind>=1;ind-=ind&(-ind)){
pas+=tree[ind];
}
return pas;
}
int main(){
cin>>n;
for(k=1;k<=n;k++){
cin>>h[k];
a[k].first=h[k];
a[k].second=k;
}
sort(a+1,a+n+1); bef=-1;
for(k=1;k<=n;k++){
if(a[k].first!=bef){
bef=a[k].first;
i++;
}
ind[a[k].second]=i;
}
for(k=1;k<=n;k++){
update(ind[k],1);
if(ind[k]!=1) b[k]=getans(ind[k]-1);
// cout<<k<<" "<<b[k]<<endl;
}
for(k=1;k<=n;k++){
update(ind[k],-1);
}
for(k=n;k>=1;k--){
update(ind[k],1);
if(ind[k]!=1)ans+=b[k]*(getans(ind[k]-1));
}
cout<<ans;
}컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
