# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
158352 | johutha | Teams (IOI15_teams) | C++14 | 4037 ms | 51776 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 <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
struct event
{
int tm;
bool st = false;
bool end = false;
int nr = -1;
};
bool evsort(event e1, event e2)
{
if (e1.tm != e2.tm) return e1.tm < e2.tm;
if (e1.st) return true;
if (e2.st) return false;
if (e1.nr == -1) return true;
return (e2.nr != -1);
}
vector<event> evs;
vector<int> st;
vector<int> en;
void init(int N, int A[], int B[])
{
for (int i = 0; i < N; i++)
{
st.push_back(A[i]);
en.push_back(B[i]);
event nw;
nw.tm = A[i];
nw.nr = i;
nw.st = true;
evs.push_back(nw);
event ene;
ene.tm = B[i];
ene.nr = i;
ene.end = true;
evs.push_back(ene);
}
}
int can(int M, int K[])
{
vector<event> evcopy = evs;
for (int i = 0; i < M; i++)
{
event mev;
mev.tm = K[i];
evcopy.push_back(mev);
}
sort(evcopy.begin(), evcopy.end(), evsort);
multiset<int> active;
for (auto e : evcopy)
{
if (e.nr == -1)
{
if (active.size() < e.tm)
{
return 0;
}
auto it = active.begin();
for (int i = 0; i < e.tm; i++)
{
it = active.erase(it);
}
}
else if (e.st)
{
active.insert(en[e.nr]);
}
else
{
if (active.find(e.tm) != active.end()) active.erase(active.find(e.tm));
}
}
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... |