Submission #799923

#TimeUsernameProblemLanguageResultExecution timeMemory
799923cig32Mountains (NOI20_mountains)C++17
100 / 100
722 ms27080 KiB
#include <bits/stdc++.h> using namespace std; #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/detail/standard_policies.hpp> using namespace __gnu_pbds; #define int long long typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ost; int32_t main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int a[n+1]; for(int i=1; i<=n; i++) cin >> a[i]; ost left, right; for(int i=3; i<=n; i++) right.insert({a[i],i}); left.insert({a[1],1}); int ans = left.order_of_key({a[2],0}) * right.order_of_key({a[2],0}); for(int i=3; i<n; i++) { left.insert({a[i-1],i-1}); right.erase({a[i],i}); ans += left.order_of_key({a[i],0}) * right.order_of_key({a[i],0}); } cout << ans << "\n"; }
#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...