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;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;
#define all(x) begin(x), end(x)
#define pb push_back
#define mp make_pair
#define f first
#define s second
const int mx = 500005;
int N;
int A[mx];
int B[mx];
vpi students;
void init(int _N, int _A[], int _B[]) {
N = _N;
for(int i = 0; i < N; i++){
A[i] = _A[i]; B[i] = _B[i];
}
for(int i = 0; i < N; i++){
students.pb(mp(A[i], B[i]));
}
sort(all(students));
}
int Rnum[mx];
int can(int M, int K[]) {
sort(K, K+M);
int Ksum = 0;
for(int i = 0; i < M; i++){
Ksum+=K[i];
if(Ksum > N) return 0;
}
for(int i = 0; i <= N; i++){
Rnum[i] = 0;
}
int curind = 0;
int curR = 0;
for(int i = 0; i < M; i++){
while(curind < N){
if(students[curind].f > K[i]) break;
Rnum[students[curind].s]++;
curind++;
}
int need = K[i];
curR = max(curR, K[i]);
while(curR <= N && need > 0){
int remov = min(need, Rnum[curR]);
need-=remov;
Rnum[curR]-=remov;
if(Rnum[curR] == 0){
curR++;
}
}
if(need > 0) return 0;
}
return 1;
}
# | 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... |