이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cross.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
long long SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int N = I.size();
vector<pll> V; V.resize(N);
for(int i = 0 ; i < N ; i++) V[i].first = I[i], V[i].second = O[i];
sort(V.begin(), V.end());
reverse(V.begin(), V.end());
int cnt = 0;
map<ll, int> MP;
long long ans = 0;
for(int i = 0 ; i < N ; i++){
if(cnt == K) {
MP.begin()->second--; cnt--;
if(MP.begin()->second == 0) MP.erase(MP.begin());
}
MP[V[i].second]++; cnt++;
if(cnt == K){
ans = max(ans, V[i].first * V[i].first + (MP.begin()->first - V[i].first) * V[i].first * 2);
}
}
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... |