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 <bits/stdc++.h>
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define chkmin(a, b) a = min(a, b)
#define chkmax(a, b) a = max(a, b)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
const int MAX_N = 5e5 + 5;
int a[MAX_N], b[MAX_N], ind[MAX_N];
int n;
void init(int N, int A[], int B[]) {
n = N;
for (int i = 0; i < n; i++) {
a[i] = A[i];
b[i] = B[i];
ind[i] = i;
}
sort(ind, ind + n, [&] (int i, int j) {
return (a[i] == a[j] ? b[i] < b[j] : a[i] < a[j]);
});
}
int can(int m, int k[]) {
priority_queue<int, vi, greater<int>> pq;
sort(k, k + m);
int last = 0;
for (int i = 0; i < m; i++) {
while (last < n && a[ind[last]] <= k[i]) {
pq.push(b[ind[last++]]);
}
while (!pq.empty() && pq.top() < k[i]) pq.pop();
if (pq.size() < k[i]) {
return 0;
}
while (k[i]--) pq.pop();
}
return 1;
}
//4
//2 4
//1 2
//2 3
//2 3
//2
//2 1 3
//2 1 1
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:40:23: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
40 | if (pq.size() < k[i]) {
| ~~~~~~~~~~^~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |