# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
830280 | skittles1412 | Teams (IOI15_teams) | C++17 | 4077 ms | 12216 KiB |
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/extc++.h"
using namespace std;
template <typename T, typename... U>
void dbgh(const T& t, const U&... u) {
cerr << t;
((cerr << " | " << u), ...);
cerr << endl;
}
#ifdef DEBUG
#define dbg(...) \
cerr << "L" << __LINE__ << " [" << #__VA_ARGS__ << "]: "; \
dbgh(__VA_ARGS__)
#else
#define dbg(...)
#define cerr \
if (false) \
cerr
#endif
#define endl "\n"
#define long int64_t
#define sz(x) int(std::size(x))
template <typename Cb>
struct Cmp {
Cb cb;
Cmp(Cb cb) : cb(cb) {}
template <typename T>
bool operator()(const T& a, const T& b) const {
return cb(a) < cb(b);
}
};
struct Solver {
vector<pair<int, int>> arr;
Solver() {}
Solver(const vector<pair<int, int>>& _arr) : arr(_arr) {
sort(begin(arr), end(arr),
Cmp([&](const pair<int, int>& p) -> int { return p.second; }));
}
bool query(vector<int> q_arr) {
sort(begin(q_arr), end(q_arr));
int n = sz(arr);
if (accumulate(begin(q_arr), end(q_arr), long(0)) > n) {
return false;
}
bool used[n] {};
for (auto& a : q_arr) {
int cnt = 0;
for (int i = 0; i < n && cnt < a; i++) {
if (used[i]) {
continue;
}
if (arr[i].first <= a && a <= arr[i].second) {
used[i] = true;
cnt++;
}
}
if (cnt != a) {
return false;
}
}
return true;
}
} solver;
void init(int n, int arrl[], int arrr[]) {
vector<pair<int, int>> arr;
for (int i = 0; i < n; i++) {
arr.emplace_back(arrl[i], arrr[i]);
}
solver = Solver(arr);
}
int can(int m, int arr[]) {
return solver.query(vector<int>(arr, arr + m));
}
Compilation message (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... |