#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=min(pq.top(),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
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:32:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(pq.size()==k) pq.pop();
~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
6 ms |
384 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |