이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <bits/stdc++.h>
const int inf = 2e9+7;
using namespace std;
int putaway(int n, int m, int t, int a[], int b[], int w[], int s[]) {
int mxa = 0, mxb = 0;
for(int i=0;i<n;i++)mxa = max(mxa, a[i]);
for(int i=0;i<m;i++)mxb = max(mxb, b[i]);
for(int i=0;i<t;i++){
if(mxa <= w[i] && mxb <= s[i])return -1;
}
multiset<pair<int, int>> wtoys;
multiset<pair<int, int>> stoys;
// weak_toys[i] = {weight, size}
// small_toys[i] = {size, weight}
for(int i=0;i<t;i++){
wtoys.insert({w[i], s[i]});
stoys.insert({s[i], w[i]});
}
multiset<pair<int, int>> robots;
for(int i=0;i<n;i++){
robots.insert({a[i], 0});
}for(int i=0;i<m;i++){
robots.insert({b[i], 1});
}
int level = 0;
while(wtoys.size()){
level++;
// cout << level << ' ';
// cout << wtoys.size() << '\n';
vector<pair<int, int>> black_list;
for(auto robot : robots){
// auto robot = *r;
if(!wtoys.size())break;
int st = robot.first;
if(robot.second == 0){
auto it = wtoys.upper_bound({st, -inf});
if(it == wtoys.begin()){black_list.push_back(robot);continue;}it--;
int f = (*it).first;
int s = (*it).second;
wtoys.erase(wtoys.find({f, s}));
stoys.erase(stoys.find({s, f}));
}else {
auto it = stoys.upper_bound({st, -inf});
if(it == stoys.begin()){black_list.push_back(robot);continue;}it--;
int f = (*it).first;
int s = (*it).second;
stoys.erase(stoys.find({f, s}));
wtoys.erase(wtoys.find({s, f}));
}//cout << st << ' ';
}
for(auto x : black_list){
robots.erase(robots.find(x));
}
}/*for(auto X : wtoys){
cout << X.first << ' ' << X.second << '\n';
}*/
return level;
}
# | 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... |