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;
int a,b,c,d,e,i,j,ii,jj,zx,xc,f[500009],dp[500009],k[500009];
pair <int, int> p[500009];
void init(int Nn, int Aa[], int Bb[]) {
b=Nn;
for(i=1; i<=b; i++){
p[i].first=Aa[i-1];p[i].second=Bb[i-1];
k[p[i].first]++;k[p[i].second+1]--;
}
for(i=1; i<=b; i++) k[i]+=k[i-1];
}
int cost(int q, int w){
int qw=0;
for(int h=1; h<=b; h++){
if(p[h].first<=q&&w<=p[h].second) qw++;
}
return qw;
}
int can(int Mm, int Kk[]) {
a=Mm;zx=0;
for(i=1; i<=a; i++){
f[i]=Kk[i-1];zx+=f[i];
}
sort(f+1,f+a+1);
if(zx>b){
return 0;
}
dp[0]=0;
for(i=1; i<=a; i++){
zx=0;
for(j=i-1; j>=1; j--){
zx=min(zx,(dp[j]-cost(f[j],f[i])));
}
dp[i]=zx+k[f[i]]-f[i];
}
zx=0;
for(i=1; i<=a; i++){
zx=min(zx,dp[i]);
}
if(zx<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... |