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>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<db,db> pdb;
typedef tuple<int,int,int,int> TP;
typedef vector<vector<ll>> mat;
const int N=2e5+5;
const ll mod=1e9+7;
int n,k;
ll ans;
pll p[N];
priority_queue<ll,vector<ll>,greater<ll>> pq;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
n=I.size(); k=K;
for(int i=1;i<=n;i++){
p[i]=pll(I[i-1],O[i-1]);
}
sort(p+1,p+1+n);
for(int i=n;i>=1;i--){
if(pq.size()==k-1){
ll v;
if(k!=1) v=min(pq.top(),p[i].se);
else v=p[i].se;
ans=max(ans,p[i].fi*(2LL*v-p[i].fi));
//cout<<p[i].fi<<" : "<<pq.top()<<" "<<" "<<v<<ans<<endl;
}
pq.push(p[i].se);
if(pq.size()==k) pq.pop();
}
return ans;
}
Compilation message (stderr)
cross.cpp: In function 'long long int SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:26:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(pq.size()==k-1){
~~~~~~~~~^~~~~
cross.cpp:34:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(pq.size()==k) pq.pop();
~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |