Submission #887872

#TimeUsernameProblemLanguageResultExecution timeMemory
887872adaawfMountains (NOI20_mountains)C++14
100 / 100
971 ms50576 KiB
#include <iostream> using namespace std; #include <ext/pb_ds/tree_policy.hpp> #include <ext/pb_ds/assoc_container.hpp> using namespace std; #define int long long namespace __gnu_pbds{ typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; } using namespace __gnu_pbds; int a[300005], f[300005], g[300005]; signed main() { int n, res = 0; cin >> n; ordered_set s, t; for (int i = 1; i <= n; i++) { cin >> a[i]; f[i] = s.order_of_key(a[i]); s.insert(a[i]); } for (int i = n; i >= 1; i--) { g[i] = t.order_of_key(a[i]); t.insert(a[i]); res += f[i] * g[i]; } cout << res; }
#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...