이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cross.h"
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 2e5+5;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
int n;
ll SelectCross(int K, vi I, vi O) {
n = I.size();
vector< ii > foo;
for(int i = 0; i< n; i++)
{
foo.pb(ii(I[i], O[i]));
}
sort(foo.begin(), foo.end());
reverse(foo.begin(), foo.end());
priority_queue<int> pq;
ll best = 0;
for(int i = 0; i< n; i++)
{
pq.push(-foo[i].s);
while(sz(pq)> K) pq.pop();
if(sz(pq) != K) continue;
best = max(best, 2LL*(-pq.top())*foo[i].f-1LL*foo[i].f*foo[i].f);
}
return best;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |