# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
284531 | IOrtroiii | Teams (IOI15_teams) | C++14 | 4089 ms | 62068 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 "teams.h"
#include <bits/stdc++.h>
using namespace std;
const int MX = 500500;
int N;
int A[MX];
int B[MX];
vector<int> add[MX];
vector<int> sub[MX];
void init(int _N, int _A[], int _B[]) {
N = _N;
for (int i = 0; i < N; ++i) {
A[i] = _A[i];
B[i] = _B[i];
add[A[i]].emplace_back(i);
sub[B[i]+1].emplace_back(i);
}
}
bool delt[MX];
int can(int M, int K[]) {
sort(K, K + M);
for (int i = 0; i < N; ++i) delt[i] = false;
set<pair<int, int>> st;
int ptr = 0;
for (int i = 0; i < M; ++i) {
while (ptr < K[i]) {
++ptr;
for (int z : add[ptr]) st.emplace(B[z], z);
for (int z : sub[ptr]) if (!delt[z]) st.erase(st.find(make_pair(B[z], z)));
}
if (st.size() < K[i]) return 0;
for (int z = 0; z < K[i]; ++z) {
int x = st.begin()->second;
st.erase(st.begin());
delt[x] = true;
}
}
return 1;
}
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... |