제출 #851428

#제출 시각아이디문제언어결과실행 시간메모리
851428NamPEMountains (NOI20_mountains)C++17
100 / 100
695 ms27288 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template <class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { ios::sync_with_stdio(0); cout.tie(0); cin.tie(0); ll n; cin >> n; vector<ll> h(n); for (ll& i : h) { cin >> i; } indexed_set<pair<ll, ll>> l, r; ll id = 0; for (ll i : h) { r.insert({i, id}); id++; } ll ans = 0; for (ll i : h) { r.erase(r.lower_bound({i, 0})); ll a = l.order_of_key({i - 1, INT_MAX}); ll b = r.order_of_key({i - 1, INT_MAX}); ans += a * b; l.insert({i, id}); id++; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...