#include "cross.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class U>
void ckmin(T &a, U b)
{
if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
if (a < b) a = b;
}
#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define SZ(x) ((int) (x).size())
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
const int MAXN = 200013;
const int INF = 1e9 + 7;
const ll LLINF = 3e18;
int N, K;
pll arr[MAXN];
priority_queue<ll, vector<ll>, greater<ll> > pq;
ll ans;
ll SelectCross(int kk, vi inner, vi outer)
{
N = SZ(inner); K = kk;
//2ab - b^2
FOR(i, 0, N)
{
arr[i] = {inner[i], outer[i]};
}
sort(arr, arr + N, greater<pii>());
// FOR(i, 0, N)
// {
// cerr << arr[i].fi << ',' << arr[i].se << endl;
// }
FOR(i, 0, K)
{
pq.push(arr[i].se);
}
ckmax(ans, arr[K - 1].fi * (2 * pq.top() - arr[K - 1].fi));
//delete the smallest, query the smallest.
FOR(i, K, N)
{
pq.push(arr[i].se);
pq.pop();
ckmax(ans, arr[i].fi * (2 * pq.top() - arr[i].fi));
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
1024 KB |
Output is correct |
6 |
Correct |
108 ms |
10600 KB |
Output is correct |
7 |
Correct |
109 ms |
10604 KB |
Output is correct |
8 |
Correct |
110 ms |
10472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
1024 KB |
Output is correct |
6 |
Correct |
108 ms |
10600 KB |
Output is correct |
7 |
Correct |
109 ms |
10604 KB |
Output is correct |
8 |
Correct |
110 ms |
10472 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
11 ms |
1024 KB |
Output is correct |
13 |
Correct |
60 ms |
5616 KB |
Output is correct |
14 |
Correct |
113 ms |
10604 KB |
Output is correct |
15 |
Correct |
114 ms |
10600 KB |
Output is correct |
16 |
Correct |
110 ms |
10600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
256 KB |
Output is correct |
2 |
Correct |
4 ms |
256 KB |
Output is correct |
3 |
Correct |
4 ms |
256 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
11 ms |
1024 KB |
Output is correct |
6 |
Correct |
108 ms |
10600 KB |
Output is correct |
7 |
Correct |
109 ms |
10604 KB |
Output is correct |
8 |
Correct |
110 ms |
10472 KB |
Output is correct |
9 |
Correct |
5 ms |
256 KB |
Output is correct |
10 |
Correct |
5 ms |
384 KB |
Output is correct |
11 |
Correct |
5 ms |
384 KB |
Output is correct |
12 |
Correct |
11 ms |
1024 KB |
Output is correct |
13 |
Correct |
60 ms |
5616 KB |
Output is correct |
14 |
Correct |
113 ms |
10604 KB |
Output is correct |
15 |
Correct |
114 ms |
10600 KB |
Output is correct |
16 |
Correct |
110 ms |
10600 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
5 ms |
384 KB |
Output is correct |
19 |
Correct |
11 ms |
1280 KB |
Output is correct |
20 |
Correct |
63 ms |
5744 KB |
Output is correct |
21 |
Correct |
91 ms |
8428 KB |
Output is correct |
22 |
Correct |
117 ms |
10604 KB |
Output is correct |
23 |
Correct |
121 ms |
10728 KB |
Output is correct |
24 |
Correct |
130 ms |
10988 KB |
Output is correct |
25 |
Correct |
120 ms |
12648 KB |
Output is correct |
26 |
Correct |
115 ms |
12648 KB |
Output is correct |