/* cerberus97 - Hanit Banga */
#include "cross.h"
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
using namespace std;
#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
const ll inf = 1e18 + 42;
ll SelectCross(int K, std::vector<int> I, std::vector<int> O) {
int N = I.size();
vector<pll> C(N);
for (int i = 0; i < N; ++i) {
C[i] = {I[i], O[i]};
}
sort(C.begin(), C.end(), greater<pll>());
priority_queue<ll, vector<ll>, greater<ll>> q;
ll best = 0;
for (int i = 0; i < N; ++i) {
q.push(C[i].second);
if (q.size() > K) {
q.pop();
}
if (i >= K - 1) {
best = max(best, C[i].first * (2 * q.top() - C[i].first));
}
}
return best;
}
Compilation message
cross.cpp: In function 'll SelectCross(int, std::vector<int>, std::vector<int>)':
cross.cpp:41:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if (q.size() > K) {
~~~~~~~~~^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
113 ms |
6760 KB |
Output is correct |
7 |
Correct |
109 ms |
6632 KB |
Output is correct |
8 |
Correct |
109 ms |
6756 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
113 ms |
6760 KB |
Output is correct |
7 |
Correct |
109 ms |
6632 KB |
Output is correct |
8 |
Correct |
109 ms |
6756 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
128 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
768 KB |
Output is correct |
13 |
Correct |
58 ms |
3772 KB |
Output is correct |
14 |
Correct |
108 ms |
6760 KB |
Output is correct |
15 |
Correct |
119 ms |
6764 KB |
Output is correct |
16 |
Correct |
113 ms |
6760 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
432 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
6 ms |
384 KB |
Output is correct |
5 |
Correct |
12 ms |
768 KB |
Output is correct |
6 |
Correct |
113 ms |
6760 KB |
Output is correct |
7 |
Correct |
109 ms |
6632 KB |
Output is correct |
8 |
Correct |
109 ms |
6756 KB |
Output is correct |
9 |
Correct |
5 ms |
384 KB |
Output is correct |
10 |
Correct |
6 ms |
128 KB |
Output is correct |
11 |
Correct |
6 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
768 KB |
Output is correct |
13 |
Correct |
58 ms |
3772 KB |
Output is correct |
14 |
Correct |
108 ms |
6760 KB |
Output is correct |
15 |
Correct |
119 ms |
6764 KB |
Output is correct |
16 |
Correct |
113 ms |
6760 KB |
Output is correct |
17 |
Correct |
5 ms |
384 KB |
Output is correct |
18 |
Correct |
6 ms |
384 KB |
Output is correct |
19 |
Correct |
13 ms |
896 KB |
Output is correct |
20 |
Correct |
66 ms |
3824 KB |
Output is correct |
21 |
Correct |
95 ms |
5228 KB |
Output is correct |
22 |
Correct |
115 ms |
6760 KB |
Output is correct |
23 |
Correct |
118 ms |
6760 KB |
Output is correct |
24 |
Correct |
141 ms |
7140 KB |
Output is correct |
25 |
Correct |
129 ms |
8808 KB |
Output is correct |
26 |
Correct |
114 ms |
8812 KB |
Output is correct |