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;
#define ll long long
#define pb push_back
typedef pair<ll,ll> pii;
const ll MAXN = 5e5+5;
const ll INF = 1e15+7;
int presum[MAXN];
//presum[i] = quantos podem equipa de i
int started[MAXN];
//started[i] = quantos A[j]<=i
void init(int N, int A[], int B[]) {
ll i;
for(i=0;i<N;i++){
presum[A[i]]++;
presum[B[i]+1]--;
started[A[i]]++;
}
for(i=1;i<=N;i++){
presum[i]+=presum[i-1];
started[i]+=started[i-1];
}
}
int can(int M, int K[]) {
int i,j,cur,x;
int dp[M+1]; dp[0]=0;
for(i=1;i<=M;i++){
dp[i] = dp[i-1] + K[i-1];
}
//dp[i] e a soma dos primeiros i valores de k
for(i=0;i<M;i++){
for(j=i;j<M;j++){
///cout<<i<<" "<<K[i]<<" "<<j<<" "<<K[j]<<" ";
cur = dp[j+1]-dp[i];
//cout<<cur<<" ";
//ver se ha pelo menos cur pessoas neste intervalo
//somar os que começaram aqui com os que ja vieram
x = presum[K[i]];
x += ( started[K[j]] - started[K[i]] );
//cout<<presum[K[i]]<<" "<<started[K[j]]<<" "<<started[K[i]]<<endl;
if(x<cur){
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... |