이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h> //:3
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define sz(x) (int)((x).size())
//#define int long long
#include "robots.h"
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const ll inf = 2e6;
const ll mod = 1e9 + 7;
const int N = 3e6 + 11;
const ll INF64 = 3e18 + 1;
const double eps = 1e-14;
const double PI = acos(-1);
//ifstream in(".in");
//ofstream out(".out");
int A, B, T, *X, *Y, *W, *S;
pi P[N];
bool f(int m){
priority_queue<int> q;
int j = 0;
for(int i = 0; i < A; i++){
for(;j < T && P[j].ff < X[i];){
q.push(P[j].ss);
j++;
}
for(int k = 0; k < m && sz(q); k++)q.pop();
}
for(int i = j; i < T; i++)q.push(P[i].ss);
for(int i = B - 1; i >= 0; i--){
for(int j = 0; j < m && sz(q); j++){
if(Y[i] <= q.top())return 0;
q.pop();
}
}
return (!sz(q));
}
int putaway(int AA, int BB, int TT, int XX[], int YY[], int WW[], int SS[]) {
A = AA, B = BB, T = TT, X = XX, Y = YY, W = WW, S = SS;
sort(X, X + A);
sort(Y, Y + B);
for(int i = 0; i < T; ++i)
if(W[i] >= X[A - 1] && S[i] >= Y[B - 1]) return -1;
for(int i = 0; i < T; i++){
P[i] = {W[i], S[i]};
}
sort(P, P + T);
int l = 1, r = T, ans = T;
while(l < r){
int mid = (l + r) >> 1;
if(f(mid))r = mid, ans = mid;else l = mid + 1;
}
return l;
}
컴파일 시 표준 에러 (stderr) 메시지
robots.cpp: In function 'int putaway(int, int, int, int*, int*, int*, int*)':
robots.cpp:65:20: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
65 | int l = 1, r = T, ans = T;
| ^~~
# | 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... |