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 pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define orta ((l+r)>>1)
#define INF 1000000009
#define mod 1000000007
#define ppair(x); cerr << "(" << x.first << ", " << x.second << ")\n";
#define bas(x) #x << ": " << x << " "
#define prarr(x, n); cerr << #x << ": "; for(int qsd = 0; qsd < n; qsd++) cerr << x[qsd] << " "; cerr << "\n";
#define prarrv(x); cerr << #x << ": "; for(int qsd = 0; qsd < (int)x.size(); qsd++) cerr << x[qsd] << " "; cerr << "\n";
using namespace std;
typedef long long ll;
int n;
vector<int> artir;
vector<int> azalt;
void init(int N, int A[], int B[]){
n = N;
artir.resize(n+1);
azalt.resize(n+1);
for (int i = 0; i <= n; i++) artir[i] = azalt[i] = 0;
for (int i = 0; i < n; i++){
artir[A[i]]++;
azalt[B[i]]++;
}
}
int can(int M, int K[]){
ll cur = 0;
ll aldim = 0;
int ki = 0;
sort(K, K+M);
for (int i = 1; i <= n; i++){
cur += artir[i];
while (K[ki] == i){
if (cur < K[ki]) return 0;
cur -= K[ki];
aldim += K[ki];
ki++;
if (ki == M) return 1;
}
if (aldim >= azalt[i]) aldim -= azalt[i];
else {
cur -= azalt[i] - aldim;
aldim = 0;
}
}
return aldim == 0;
}
# | 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... |