This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//雪花飄飄北風嘯嘯
//天地一片蒼茫
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |