이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "robots.h"
using namespace std;
#define fi first
#define se second
#define _size(x) (int)x.size()
#define BIT(i, x) ((x >> i) & 1)
#define MASK(n) ((1 << n) - 1)
#define REP(i, n) for (int i = 0, _n = (n); i < _n; i++)
#define FOR(i, a, b) for (int i = a, _b = (b); i <= _b; i++)
#define FORD(i, a, b) for (int i = a, _b = (b); i >= _b; i--)
#define FORB1(i, mask) for (int i = mask; i > 0; i ^= i & - i)
#define FORB0(i, n, mask) for (int i = ((1 << n) - 1) ^ mask; i > 0; i ^= i & - i)
#define FORALL(i, a) for (auto i: a)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
int putaway(int a, int b, int t, int x[], int y[], int w[], int s[]) {
sort(x, x + a);
sort(y, y + b);
int l = 0;
int r = t + 1;
while (l < r) {
int mid = (l + r) / 2;
vector<int> ids, used(t);
REP(i, t) ids.push_back(i);
sort(ids.begin(), ids.end(), [&] (const int i, int j) { return w[i] < w[j]; });
priority_queue<pair<int, int>> pq;
int j = 0;
REP(i, a) {
int value = x[i];
while (j < t && w[ids[j]] < value) pq.push({s[ids[j]], ids[j++]});
int cnt = 0;
while (!pq.empty() && cnt < mid) {
int id = pq.top().se;
pq.pop();
used[id]++;
cnt++;
}
}
vector<int> g;
REP(i, t) if (!used[i]) g.push_back(s[i]);
sort(g.begin(), g.end());
j = 0;
REP(i, b) {
int value = y[i], cnt = 0;
while (j < _size(g) && cnt < mid && g[j] < value) {
cnt++;
j++;
}
}
if (j == _size(g)) r = mid;
else l = mid + 1;
}
return (l > t ? - 1 : l);
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:33:73: warning: operation on 'j' may be undefined [-Wsequence-point]
33 | while (j < t && w[ids[j]] < value) pq.push({s[ids[j]], ids[j++]});
| ~^~
# | 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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |