이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
컴파일 시 표준 에러 (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... |