이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include "bits/stdc++.h"
using namespace std;
vector<pair<int,int>>v;
int mid;
deque<int>a,b;
unordered_map<int,int>mp;
bool bol;
bool slv(){
if(!bol){
priority_queue<int>pq;
int l=0;
for(int i=0;i<a.size();i++){
while(l<v.size()&&a[i]>v[l].first){
pq.push(v[l].second);
l++;
}
int k=mid;
while(pq.size()&&k--){
if(!bol)mp[pq.top()]++;
pq.pop();
}
}
return pq.empty();
}
int g=0;
int l=0;
for(int i=0;i<a.size();i++){
while(l<v.size()&&a[i]>v[l].first){
if(bol&&mp[v[l].first])mp[v[l].first]--;
else g++;
l++;
}
int k=mid;
g=max(0,g-k);
}
while(l<v.size()&&g==0){
if(bol&&mp[v[l].first])mp[v[l].first]--;
else g++;;
l++;
}
return g==0;
}
int putaway(int A, int B, int t, int x[], int y[], int w[], int s[]) {
if(A>B){
swap(A,B);
swap(x,y);
swap(w,s);
}
for(int i=0;i<t;i++)v.push_back({w[i],s[i]});
for(int i=0;i<A;i++)a.push_back(x[i]);
for(int i=0;i<B;i++)b.push_back(y[i]);
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int l=1,r=t,f=-1;
vector<pair<int,int>>vec=v;
sort(vec.begin(),vec.end());
vector<pair<int,int>>vec2=v;
for(auto &i:vec2)swap(i.first,i.second);
sort(vec2.begin(),vec2.end());
while(l<=r){
mid=(l+r)/2;
swap(v,vec);
mp.clear();
bol=0;
slv();
swap(v,vec);
bol=1;
v=vec2;
swap(a,b);
swap(v,vec2);
bool bl=slv();
swap(v,vec2);
swap(a,b);
if(bl){
r=mid-1;
f=mid;
}else l=mid+1;
}
return f;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'bool slv()':
robots.cpp:13:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for(int i=0;i<a.size();i++){
| ~^~~~~~~~~
robots.cpp:14:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | while(l<v.size()&&a[i]>v[l].first){
| ~^~~~~~~~~
robots.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::deque<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i=0;i<a.size();i++){
| ~^~~~~~~~~
robots.cpp:29:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | while(l<v.size()&&a[i]>v[l].first){
| ~^~~~~~~~~
robots.cpp:37:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | while(l<v.size()&&g==0){
| ~^~~~~~~~~
# | 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... |