# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
63293 | Kubalionzzale | Teams (IOI15_teams) | C++14 | 4022 ms | 92372 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 <algorithm>
#include <iostream>
#include <vector>
#include <set>
std::vector< std::vector<int> > vec(500010);
int n;
void init(int N, int A[], int B[]) {
n = N;
for (int i = 0; i < n; ++i)
{
vec[A[i]].push_back(B[i]);
}
}
int can(int m, int a[]) {
int sum = 0;
for (int i = 0; i < m; ++i)
{
sum += a[i];
if (sum > n)
{
return 0;
}
}
std::sort(a, a + m);
std::multiset<int> set;
int last = 0;
for (int i = 0; i < m; ++i)
{
for (int k = last + 1; k <= a[i]; ++k)
{
for (int j = 0; j < vec[k].size(); ++j)
{
set.insert(vec[k][j]);
}
}
last = a[i];
for (auto it = set.begin(); it != set.end();)
{
if (*it < a[i])
it = set.erase(it);
else
break;
}
int howMany = a[i];
if (set.size() < howMany)
return 0;
int cnt = 0;
for (auto it = set.begin(); it != set.end() && cnt < howMany; ++cnt)
{
it = set.erase(it);
}
}
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... |