Submission #259695

#TimeUsernameProblemLanguageResultExecution timeMemory
259695IOrtroiiiMountains (NOI20_mountains)C++14
24 / 100
797 ms24568 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int N; cin >> N; vector<int> H(N); for (int i = 0; i < N; ++i) cin >> H[i]; vector<int> L(N), R(N); ordered_set<pair<int, int>> st; for (int i = 0; i < N; ++i) { L[i] = st.order_of_key({H[i], -1}); st.insert({H[i], i}); } st.clear(); for (int i = N - 1; i >= 0; --i) { R[i] = st.order_of_key({H[i], -1}); st.insert({H[i], i}); } int64_t ans = 0; for (int i = 0; i < N; ++i) ans += int64_t(L[i]) * R[i]; cout << ans << '\n'; return 0; }
#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...