#include "cross.h"
#include<bits/stdc++.h>
#define sz(x) ((int)x.size())
#define pb push_back
#define ii pair<int,int>
#define st first
#define nd second
#define ll long long
#define N 200005
#define inf 1000000000
#define MOD 1000000007
using namespace std;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
ll ans=0;
multiset<int> s;
int n=sz(I);
vector<ii> a(n);
for(int i=0;i<n;i++) {
a[i]={I[i],O[i]};
}
sort(a.begin(),a.end(),[](ii x,ii y) {
if(x.st==y.st) return x.nd>y.nd;
return x.st<y.st;
});
for(int i=n-1;i>=0;i--) {
if(sz(s)==K-1) ans=max(ans,2ll*(min(*s.begin(),a[i].nd))*a[i].st-(ll)a[i].st*a[i].st);
s.insert(a[i].nd);
while(sz(s)>K-1) s.erase(s.begin());
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |