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 <bits/stdc++.h>
using namespace std;
#include "robots.h"
//#define DEBUGGING
void __print(size_t i) { std::cerr << i; }
void __print(int i) { std::cerr << i; }
void __print(long long int i) { std::cerr << i; }
void __print(const char *c) { std::cerr << c; }
template<typename T>
void __print(T& t) { std::cerr <<"{";int f = 0; for (auto& i : t) { std::cerr << ((f++) ? ", ": ""); __print(i); } std::cerr << "}"; }
void _print() { std::cerr << "]\n"; }
template<typename T, typename... V>
void _print(T t, V... v) { __print(t); if (sizeof...(v)) std::cerr << ", "; _print(v...); }
#ifdef DEBUGGING
#define debug(x...) std::cerr << "[" << (#x) << "] = ["; _print(x)
#else
#define debug(x...)
#endif
int ceil_div(int a, int b)
{
debug(a, b);
return (a + b-1) / b;
}
constexpr static int ASIZE = 50000;
int acount[ASIZE];
constexpr static int SIZE = 1000;
int counts[SIZE+1][SIZE+1];
int putaway(int a, int b, int t, int x[], int y[], int w[], int s[])
{
if (b == 0)
{
sort(x, x + a);
for (int i = 0; i < t; i++)
{
int index = upper_bound(x, x + a, w[i]) - x;
if (index == a)
return -1;
acount[index]++;
}
int prefix = 0;
int cost = 0;
for (int i = a-1; i >= 0; i--)
{
prefix += acount[i];
cost = max(cost, ceil_div(prefix, a - i));
}
return cost;
}
sort(x, x + a);
sort(y, y + b);
for (int i = 0; i < t; i++)
{
int xx = upper_bound(x, x + a, w[i]) - x;
int yy = upper_bound(y, y + b, s[i]) - y;
if (xx == a && yy == b)
return -1;
debug(xx, yy);
counts[xx][yy]++;
}
int cost = 0;
for (int i = a; i >= 0; i--)
{
for (int j = b; j >= 0; j--)
{
if (i == a && j == b)
continue;
debug(i, j, counts[i][j]);
if (i < a)
counts[i][j] += counts[i+1][j];
if (j < b)
counts[i][j] += counts[i][j+1];
if (i < a && j < b)
counts[i][j] -= counts[i+1][j+1];
cost = max(cost, ceil_div(counts[i][j], a + b - i - j));
}
}
return cost;
}
# | 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... |