# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1135433 | monostack | Mountains (NOI20_mountains) | C++20 | 535 ms | 47408 KiB |
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define int long long
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
void init(){
ios_base::sync_with_stdio(0);
cin.tie(NULL);
if(fopen("input.txt","r")){
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
}
int32_t main(){
init();
int n, ans = 0; cin>>n;
vector<pair<int,int>> a(n);
for(int i=0; i < n; i++) cin>>a[i].ff, a[i].ss=i;
ordered_set<pair<int,int>> _l, _g;
vector<int> less_(n,0), greater_(n,0);
for(int i = 0; i < n; i++){
less_[i] = _l.order_of_key({a[i].ff,-1});
greater_[n-i-1] = _g.order_of_key({a[n-i-1].ff,-1});
_l.insert(a[i]);
_g.insert(a[n-i-1]);
}
for(int i = 0; i < n; i++) ans += less_[i]*greater_[i];
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... |