Submission #1173493

#TimeUsernameProblemLanguageResultExecution timeMemory
1173493qrnMountains (NOI20_mountains)C++20
100 / 100
812 ms21564 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> using namespace std; using namespace __gnu_pbds; template<class T> using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; #define SPEED \ ios_base::sync_with_stdio(0); \ cin.tie(NULL); \ cout.tie(NULL); #define pb push_back #define ins insert #define fi first #define se second #define endl "\n" #define ALL(x) x.begin(), x.end() #define sz(x) x.size() #define intt long long const intt mod = 1e9 + 7; const intt base = 31; const intt inf = 1e9; const intt mxN = 1e3 + 5; const intt L = 21; void solve() { intt n; cin >> n; vector<intt> a(n); for(intt i = 0; i < n; i++) { cin >> a[i]; } ordered_multiset<intt> mst, cmst; for(intt i = 1; i < n; i++) { mst.insert(a[i]); } cmst.insert(a[0]); intt ans = 0; for(intt i = 1; i < n - 1; i++) { mst.erase(mst.find_by_order(mst.order_of_key(a[i]))); intt sol = cmst.order_of_key(a[i]); intt sag = mst.order_of_key(a[i]); ans += sol * sag; cmst.insert(a[i]); // cout << i << ": " << ans << endl; } cout << ans << endl; } signed main() { SPEED; intt tst = 1; // cin >> tst; while (tst--) { solve(); } }
#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...