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 "teams.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll linf = ll(1e18);
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> p2;
#define rep(i, high) for (int i = 0; i < high; i++)
#define repp(i, low, high) for (int i = low; i < high; i++)
#define repe(i, container) for (auto& i : container)
#define sz(container) ((int)container.size())
#define all(x) begin(x),end(x)
#if _LOCAL
#define assert(x) if (!(x)) __debugbreak()
#endif
int n;
vi a;
vi b;
typedef pair<double, int> pt;
vector<p2> pts;
void init(int N, int A[], int B[])
{
n = N;
a.resize(N);
b.resize(N);
rep(i, N) a[i] = A[i], b[i] = B[i];
rep(i, n)
{
pts.emplace_back(b[i], a[i]);
}
sort(all(pts));
}
int rectangle_sum(int xlo, int xhi, int ylo, int yhi)
{
int ret = 0;
repp(i, ylo, yhi+1)
{
ret += pts[i].second >= xlo && pts[i].second <= xhi;
}
return ret;
}
const double inf = 2e9;
int can(int m, int K[]) {
//cout << rectangle_sum(1, 3, 1, 3);
vi k(m);
rep(i, m) k[i] = K[i];
sort(all(k));
int lo = 0;
rep(i, m)
{
while (lo < sz(pts) && pts[lo].first < k[i])
{
lo++;
}
if (rectangle_sum(0, k[i], lo, n-1)<k[i])
{
return 0;
}
int lob = lo;
int hib = n;
while (lob+1<hib)
{
int mid = (lob + hib) / 2;
if (rectangle_sum(0, k[i], lo, mid) < k[i])
{
lob = mid;
}
else hib = mid;
}
lo = lob+1;
}
return 1;
}
# | 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... |