Submission #1135433

#TimeUsernameProblemLanguageResultExecution timeMemory
1135433monostackMountains (NOI20_mountains)C++20
100 / 100
535 ms47408 KiB
#include<bits/stdc++.h> using namespace std; #include<ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define int long long #define ff first #define ss second #define all(x) x.begin(), x.end() void init(){ ios_base::sync_with_stdio(0); cin.tie(NULL); if(fopen("input.txt","r")){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); } } int32_t main(){ init(); int n, ans = 0; cin>>n; vector<pair<int,int>> a(n); for(int i=0; i < n; i++) cin>>a[i].ff, a[i].ss=i; ordered_set<pair<int,int>> _l, _g; vector<int> less_(n,0), greater_(n,0); for(int i = 0; i < n; i++){ less_[i] = _l.order_of_key({a[i].ff,-1}); greater_[n-i-1] = _g.order_of_key({a[n-i-1].ff,-1}); _l.insert(a[i]); _g.insert(a[n-i-1]); } for(int i = 0; i < n; i++) ans += less_[i]*greater_[i]; cout<<ans; }

Compilation message (stderr)

Mountains.cpp: In function 'void init()':
Mountains.cpp:18:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |         freopen("input.txt","r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Mountains.cpp:19:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |         freopen("output.txt","w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#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...