이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/*
Procrastination is the art of keeping up with yesterday
*/
#include <bits/stdc++.h>
#include "robots.h"
#define pb push_back
#define fi first
#define se second
#define faster ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair <int, int>;
mt19937_64 Rand(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 1e6 + 1;
//const int Mod = 1e9 + 7;
int n, m, k;
int X[maxN];
int Y[maxN];
int W[maxN];
int S[maxN];
int I[maxN];
int J[maxN];
bool mark[maxN];
bool check(int mid){
priority_queue <pii> PQ;
int j = 1;
fill(mark + 1, mark + k + 1, 0);
for (int i = 1; i <= n; ++i){
while (j <= k && W[I[j]] < X[i]){
PQ.push({S[I[j]], I[j]});
++j;
}
for (int _ = 0; _ < mid && PQ.size(); ++_){
mark[PQ.top().se] = 1;
PQ.pop();
}
}
j = k;
for (int i = m; i >= 1; --i){
int cnt = 0;
while (j >= 1 && cnt < mid){
if (!mark[J[j]]){
if (S[J[j]] >= Y[i]) return 0;
++cnt;
}
--j;
}
}
return 1;
}
int putaway(int A, int B, int C, int x[], int y[], int w[], int s[]){
n = A;
m = B;
k = C;
int l = 1, r = maxN;
for (int i = 1; i <= n; ++i) X[i] = x[i - 1];
for (int i = 1; i <= m; ++i) Y[i] = y[i - 1];
for (int i = 1; i <= k; ++i) W[i] = w[i - 1];
for (int i = 1; i <= k; ++i) S[i] = s[i - 1];
for (int i = 1; i <= k; ++i) I[i] = J[i] = i;
sort(I + 1, I + k + 1,[&](const auto &i, const auto &j){
return W[i] < W[j];
});
sort(J + 1, J + k + 1,[&](const auto &i, const auto &j){
return S[i] < S[j];
});
while (l < r){
int mid = (l + r) >> 1;
if (check(mid)) r = mid;
else l = mid + 1;
}
if (l == maxN) return -1;
return l;
}
# | 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... |