Submission #333084

#TimeUsernameProblemLanguageResultExecution timeMemory
333084errorgornCrosses on the Grid (FXCUP4_cross)C++17
100 / 100
104 ms14168 KiB
//雪花飄飄北風嘯嘯 //天地一片蒼茫 #include "cross.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace std; using namespace __gnu_pbds; using namespace __gnu_cxx; #define ll long long #define ii pair<ll,ll> #define iii pair<ii,ll> #define fi first #define se second #define endl '\n' #define debug(x) cout << #x << " is " << x << endl #define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--)) #define all(x) (x).begin(),(x).end() #define sz(x) (int)(x).size() long long SelectCross(int k, std::vector<int> I, std::vector<int> O) { int n = I.size(); vector<ii> v; rep(x,0,n){ v.push_back(ii(O[x],I[x])); } sort(all(v)); reverse(all(v)); priority_queue<ll,vector<ll>,greater<ll> > pq; ll ans=0; rep(x,0,n){ pq.push(v[x].se); if (sz(pq)>k) pq.pop(); if (sz(pq)==k){ //cout<<pq.top()<<" "<<v[x].fi<<endl; ans=max(ans,pq.top()*v[x].fi*2-pq.top()*pq.top()); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...