이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
long long n, pos, sum;
vector<pair<int, int> > sz;
priority_queue<pair<int, int> > q;
vector<int> kerd;
//bool can(int m, vector<int> a) {
bool can(int m, int a[]) {
pos=0, sum=0;
for (int i=0; i<m; i++) sum+=a[i];
if (sum>n) return 0;
kerd.clear();
for (int i=0; i<m; i++) for (int j=0; j<a[i]; j++) kerd.push_back(a[i]);
for (int i=0; i<n; i++) q.push(sz[i]);
sort(kerd.begin(), kerd.end());
for (int i=0; i<sum; i++) {
while(q.size()>0 && kerd[i]>-q.top().first || kerd[i]<q.top().second) q.pop();
if (q.size()==0) return 0;
q.pop();
}
return 1;
}
//void init(int p, vector<int> a, vector<int> b) {
void init(int p, int a[], int b[]) {
n=p;
for (int i=0; i<n; i++) sz.push_back({-b[i], a[i]});
}
컴파일 시 표준 에러 (stderr) 메시지
teams.cpp: In function 'bool can(int, int*)':
teams.cpp:18:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
18 | while(q.size()>0 && kerd[i]>-q.top().first || kerd[i]<q.top().second) q.pop();
| ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |