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>
#define ll long long
#define pii pair<int, int>
using namespace std;
int n;
vector<pii> v;
void init(int N, int A[], int B[])
{
n = N;
for (int i = 0; i < n; i++)
{
v.push_back({A[i], B[i]});
}
}
int can(int M, int K[])
{
sort(K, K + M);
vector<int> events[n + 1];
fill(events, events + n + 1, vector<int>());
for (int i = 0; i < n; i++)
{
events[v[i].first].push_back(0);
if(v[i].second + 1 <= n){
events[v[i].second + 1].push_back(1);
}
}
for (int i = 0; i <= n; i++)
{
sort(events[i].begin(), events[i].end());
}
int j = 0;
int cnt = 0;
int used = 0;
for (int x = 0; x <= n; x++)
{
for(int e:events[x]){
if(e == 0){
++cnt;
}
else{
--cnt;
used = max(0, used - 1);
}
}
while(x == K[j]){
if(cnt - used < K[j]){
return false;
}
used += K[j];
++j;
if(j == M) break;
}
}
return true;
}
# | 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... |