# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
282548 | SamAnd | 팀들 (IOI15_teams) | C++17 | 4067 ms | 38648 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;
#define m_p make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
typedef long long ll;
const int N = 500005;
struct ban
{
int l, r;
};
bool operator<(const ban& a, const ban& b)
{
return a.l < b.l;
}
int n;
ban a[N];
void init(int N_, int A[], int B[])
{
n = N_;
for (int i = 0; i < n; ++i)
{
a[i].l = A[i];
a[i].r = B[i];
}
sort(a, a + n);
}
int m;
int b[N];
int can(int M_, int K[])
{
m = M_;
for (int i = 0; i < m; ++i)
b[i] = K[i];
sort(b, b + m);
ll sum = 0;
for (int i = 0; i < m; ++i)
sum += b[i];
if (sum > n)
return 0;
multiset<int> s;
int j = 0;
for (int i = 0; i < m; ++i)
{
while (j < n && a[j].l <= b[i])
s.insert(a[j++].r);
while (!s.empty() && *s.begin() < b[i])
s.erase(s.begin());
if (sz(s) < b[i])
return 0;
for (int j = 0; j < b[i]; ++j)
s.erase(s.begin());
}
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... |