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 F first
#define S second
#define pb push_back
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
int n;
vector<pii> arr;
multiset<int> s;
int kth;
long long SelectCross(int k, std::vector<int> I, std::vector<int> O) {
int n = I.size();
LL ret=0;
for(int i=0; i<n; i++){
arr.pb({I[i], O[i]});
}
sort(arr.begin(), arr.end());
for(int i=0; i<n; i++)printf("%d %d\n", arr[i].F, arr[i].S);
for(int i=n-1; i>=n-k; i--){
s.insert(arr[i].S);
}
multiset<int>::iterator itt=s.begin();
ret=(LL)arr[n-k].F*((LL)(*itt)*2-(LL)arr[n-k].F);
for(int i=n-k-1; i>=0; i--){
multiset<int>::iterator it=s.begin();
if(*it<arr[i].S){
s.erase(it);
s.insert(arr[i].S);
}
it=s.begin();
ret=max(ret, (LL)arr[i].F*((LL)(*it)*2-(LL)arr[i].F));
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |