# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
769429 | boris_mihov | 로봇 (IOI13_robots) | C++17 | 3033 ms | 48712 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robots.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <bitset>
#include <set>
typedef long long llong;
const int MAXN = 1000000 + 10;
const int MAXAB = 50000 + 10;
int n;
int a, b;
int w[MAXN];
int s[MAXN];
int wX[MAXN];
int sX[MAXN];
int permX[MAXN];
std::multiset <int> vals;
int check(int times, int X[], int Y[])
{
vals.clear();
int ptr = 0;
int cntDestroyed = 0;
for (int curr = 1 ; curr <= a ; ++curr)
{
while (ptr + 1 <= n && wX[ptr + 1] <= X[curr - 1])
{
ptr++;
vals.insert(sX[ptr]);
}
for (int t = 0 ; t < times && vals.size() ; ++t)
{
vals.erase(std::prev(vals.end()));
}
}
while (ptr + 1 <= n)
{
ptr++;
vals.insert(sX[ptr]);
}
for (int curr = 1 ; curr <= b && vals.size() ; ++curr)
{
for (int t = 0 ; t < times && vals.size() ; ++t)
{
auto it = vals.upper_bound(Y[curr - 1]);
if (it == vals.begin())
{
break;
} else
{
it = std::prev(it);
vals.erase(it);
}
}
}
return vals.empty();
}
int putaway(int A, int B, int T, int X[], int Y[], int W[], int S[])
{
a = A;
b = B;
n = T;
for (int i = 1 ; i <= n ; ++i)
{
w[i] = W[i - 1] + 1;
s[i] = S[i - 1] + 1;
}
std::iota(permX + 1, permX + 1 + n, 1);
std::sort(permX + 1, permX + 1 + n, [&](const int &a, const int &b)
{
return w[a] < w[b];
});
for (int i = 1 ; i <= n ; ++i)
{
wX[i] = w[permX[i]];
sX[i] = s[permX[i]];
}
std::sort(X, X + a);
std::sort(Y, Y + b);
for (int i = 1 ; i <= n ; ++i)
{
if (w[i] > X[a - 1] && s[i] > Y[b - 1])
{
return -1;
}
}
// std::cout << "byW\n";
// for (int i = 1 ; i <= n ; ++i)
// {
// std::cout << w[sortedX.perm[i]] << ' ' << s[sortedX.perm[i]] << '\n';
// }
// std::cout << "byS\n";
// for (int i = 1 ; i <= n ; ++i)
// {
// std::cout << w[sortedY.perm[i]] << ' ' << s[sortedY.perm[i]] << '\n';
// }
int pw = -1;
while (!check(1 << pw + 1, X, Y)) pw++;
int l = (pw == -1 ? 0 : (1 << pw)), r = (1 << pw + 1), mid;
while (l < r - 1)
{
mid = (l + r) / 2;
if (!check(mid, X, Y)) l = mid;
else r = mid;
}
return r;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |