Submission #294682

#TimeUsernameProblemLanguageResultExecution timeMemory
294682crossing0verMountains (NOI20_mountains)C++17
100 / 100
1162 ms32084 KiB
#include<bits/stdc++.h> #define ll long long #define pii pair<ll,int> #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; using namespace std; #define oset tree<pii,null_type,less<pii>,rb_tree_tag,tree_order_statistics_node_update> ll a[300005],L[300005],R[300005]; main() { oset s; int n; cin >> n; for (int i = 1; i <= n; i++) cin >> a[i]; for (int i =1 ; i <= n; i++) { L[i] = s.order_of_key({a[i],0}); s.insert({a[i],i}); } s.clear(); ll ans = 0; for (int i = n; i > 0; i--) { R[i] = s.order_of_key({a[i],0}); s.insert({a[i],i}); ans += (ll)L[i]*R[i]; } cout << ans; }

Compilation message (stderr)

Mountains.cpp:10:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main() {
      |      ^
#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...