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 <iostream>
#include <fstream>
#include <cfloat>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cmath>
#include <climits>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vvvi> vvvvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<string> vs;
#define fir first
#define sec second
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
int num;
vpii pref;
void init(int N, int* A, int* B) {
num = N;
pref = vpii(N);
for (int i = 0; i < N; i++) {
pref[i] = mp(A[i], B[i]);
}
sort(pref.begin(), pref.end());
}
int can(int M, int* K) {
sort(K, K+M);
int i = 0, j = 0, inc;
bool pos;
while(i < num && j < M) {
if (pref[i].first > K[j]) return 0;
if (pref[i].second >= K[j]) {
pos = true;
inc = i+1;
for (int n = j+1; n < j+K[j]; n++) {
if (pref[n].second >= K[j]) inc = n+1;
else {
pos = false;
break;
}
}
i = inc;
if (pos) j++;
} else i++;
}
return j == M;
}
# | 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... |