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 <bits/stdc++.h>
#include "teams.h"
using namespace std;
typedef long long ll;
typedef double ld;
#define pb push_back
#define sz(x) int32_t(x.size())
#define all(x) x.begin(),x.end()
#define F first
#define S second
int n;
vector<pair<int, int>> v;
void init(int N, int A[], int B[]) {
n = N;
for (int i = 0; i < n; i++) {
v.pb({B[i], A[i]});
}
sort(all(v));
}
int can(int M, int K[]) {
sort(K, K+M);
int id = 0, rem = K[0];
for (int i = 0; i < n && id < M; i++) {
if (v[i].S <= K[id] && K[id] <= v[i].F) {
rem--;
if (!rem) {
id++;
if (id < M)rem = K[id];
}
}
}
return (id == M);
}
/*int main () {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int a[] = {1, 2, 2, 2}, b[] = {2, 3, 3, 4};
init(4, a, b);
int c[] = {1, 3};
cout << can(2, c);
}*/
# | 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... |