This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "robots.h"
#include <bits/stdc++.h>
using namespace std;
#ifdef ONPC
#include"debug.h"
#else
#define debug(...) 42
#endif
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
const int mod = 1e9 + 7;
const int MAXN = 1e6 + 15;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[]) {
sort(X, X + A);
sort(Y, Y + B);
if (A + B == 2 && T == 2){
if (B == 2){
swap(A, B);
swap(X, Y);
swap(W, S);
}
if (A == 2){
if (min(W[0], W[1]) < X[0] && max(W[0], W[1]) < X[1]){
return 1;
}
if (max(W[0], W[1]) < X[1]){
return 2;
}
return -1;
}
if ((W[0] < X[0] && S[1] < Y[0]) || (W[1] < X[0] && S[0] < Y[0])){
return 1;
}
if (max(W[0], W[1]) < X[0] || max(S[0], S[1]) < Y[0]){
return 2;
}
return -1;
}
vector<pii> v;
for (int i = 0; i < A; i++){
v.pb({X[i], 0}); // robots
}
for (int i = 0; i < T; i++){
v.pb({W[i], 1}); // toys
}
sort(all(v), greater<>());
if (v[0].first == 1) return -1;
int s[2] = {};
int ans = 0;
for (auto [x, b] : v){
s[b] ++;
if (s[0] != 0) ckmax(ans, (s[1] + s[0] - 1) / s[0]);
}
return ans;
}
Compilation message (stderr)
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:58:12: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
58 | for (auto [x, b] : v){
| ^
# | 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... |