Submission #799920

#TimeUsernameProblemLanguageResultExecution timeMemory
799920cig32Mountains (NOI20_mountains)C++17
2 / 100
535 ms27096 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<int, null_type, less<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]); left.insert(a[1]); int ans = left.order_of_key(a[2]) * right.order_of_key(a[2]); for(int i=3; i<n; i++) { left.insert(a[i-1]); right.erase(a[i]); ans += left.order_of_key(a[i]) * right.order_of_key(a[i]); } 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...