Submission #894613

#TimeUsernameProblemLanguageResultExecution timeMemory
894613IWKRMountains (NOI20_mountains)C++17
100 / 100
703 ms48416 KiB
#include <bits/stdc++.h> #include <bits/extc++.h> using namespace std; using namespace __gnu_pbds; #define int long long template <typename T> using pbds_set = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); pbds_set<int> s; pbds_set<int> t; int n; cin >> n; int arr[n]; cin >> arr[0]; s.insert(arr[0]); int demon[n]; demon[0] = 0; int ans = 0; for (int i = 1; i < n; i++) { cin >> arr[i]; demon[i] = s.order_of_key(arr[i]); s.insert(arr[i]); } t.insert(arr[n - 1]); for (int i = n - 2; i >= 0; i--) { int a = t.order_of_key(arr[i]); ans += demon[i] * a; t.insert(arr[i]); } 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...