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;
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab (int x ) { return (x>0?x:-x); }
const int MaxN = 5e5+5;
pi st[MaxN];
int n ;
void init(int N,int a[],int b[]){
n = N ;
for(int i = 0 ; i < n ;i++ ){
st[i]={a[i],b[i]};
}
sort(st,st+n);
}
bool in(int x , pi p ){
return (x>=p.fi && x<=p.se);
}
bool comp(int a , int b ){
return (st[a].se < st[b].se);
}
int can(int M,int K[]){
sort(K,K+M);
bool done[n];
memset(done,0,sizeof done);
for(int i = 0 ; i < M ; i++ ){
int k = K[i];
vector<int> p;
for(int j = 0 ; j < n ; j++ ){
if( !done[j] ){
if( in(K[i],st[j] ) ) p.pb(j);
}
}
sort(all(p),comp);
if( p.size() < k )return 0 ;
for(int j = 0 ; j < k ; j++ )done[p[j]]=1;
}
return 1 ;
}
// int main(){
// int a[]={1,2,2,2},b[]={2,3,3,4};
// init(4,a,b);
// int K[]={1,3},KK[]={1,1};
// cout << can(2,K)<<" " << can(2,KK)<<endl;
// }
Compilation message (stderr)
teams.cpp: In function 'int can(int, int*)':
teams.cpp:49:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if( p.size() < k )return 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... |