이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
#define forn(i,n) for(int i=0; i<n; ++i)
#define pb push_back
#define all(x) x.begin(), x.end()
#define pi pair<int,int>
#define f first
#define s second
using ll = long long;
struct toy {
int w,s,i;
};
bool foo(toy a, toy b) {
return a.w < b.w;
}
int check(int a, int b, int t, vector<int> x, vector<int> y, vector<int> w, vector<int> s, int mid) {
int tot=0;
vector<int> vis(t);
vector<toy> v;
forn(i,t) v.pb({w[i],s[i],i});
sort(all(v),foo);
int p=0;
priority_queue<pi> q;
forn(i,a) {
while (p<v.size() && v[p].w<x[i]) {
q.push({v[p].s,i});
++p;
}
forn(iter,mid) {
if (!q.size()) break;
auto it=q.top(); q.pop();
vis[it.s]=1;
++tot;
}
}
v.clear();
while (q.size()) q.pop();
forn(i,t) if (!vis[i]) v.pb({s[i],w[i],i});
p=0;
forn(i,b) {
while (p<v.size() && v[p].w<y[i]) {
q.push({v[p].s,i});
++p;
}
forn(iter,mid) {
if (!q.size()) break;
auto it=q.top(); q.pop();
vis[it.s]=1;
++tot;
}
}
return tot==t;
}
int putaway(int a, int b, int t, int X[], int Y[], int W[], int S[]) {
vector<int> x,y,w,s;
forn(i,a) x.pb(X[i]);
forn(i,b) y.pb(Y[i]);
forn(i,t) w.pb(W[i]),s.pb(S[i]);
sort(all(x));
sort(all(y));
int l=0, r=t+1;
while (l<r) {
int mid=(l+r)>>1;
if (check(a,b,t,x,y,w,s,mid)) r=mid;
else l=mid+1;
}
if (r==t+1) return -1;
return r;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'int check(int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, int)':
robots.cpp:31:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<toy>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | while (p<v.size() && v[p].w<x[i]) {
| ~^~~~~~~~~
robots.cpp:49:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<toy>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
49 | while (p<v.size() && v[p].w<y[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... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |