Submission #389768

#TimeUsernameProblemLanguageResultExecution timeMemory
389768PedroBigManTeams (IOI15_teams)C++14
0 / 100
4067 ms35988 KiB
#include "teams.h"
/*
Author of all code: Pedro BIGMAN Dias
Last edit: 15/02/2021
*/
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <list>
#include <iomanip>
#include <stdlib.h>
#include <time.h>
#include <cstring>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=(ll) a; i<(ll) b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define whole(x) x.begin(),x.end()
#define DEBUG(i) cout<<"Pedro Is The Master "<<i<<endl
#define INF 500000000LL
#define EPS 0.00000001
#define pi 3.14159
ll mod=1000000007LL;

template<class A=ll> 
void Out(vector<A> a) {REP(i,0,a.size()) {cout<<a[i]<<" ";} cout<<endl;}

template<class A=ll>
void In(vector<A> &a, ll N) {A cur; REP(i,0,N) {cin>>cur; a.pb(cur);}} 

ll N; vector<pl> p;

void init(int n, int A[], int B[])
{
	N = (ll) n;
	REP(i,0,N) {p.pb({(ll) A[i], (ll) B[i]});}
	return;
}

int can(int M, int k[]) 
{
	vector<pl> mp; vector<ll> K; REP(i,0,M) {K.pb((ll) k[i]);}
	sort(whole(K));
	REP(i,0,N)
	{
		ll l = (ll) (lower_bound(whole(K),p[i].ff) - K.begin()); ll r = (ll) (upper_bound(whole(K),p[i].ss) - K.begin()) - 1LL;
		if(l>r) {mp.pb({-1,-1});} else {mp.pb({l,r});}
	}
	sort(whole(mp));
	ll ind=0LL;
	REP(i,0,M)
	{
		ll needed=K[i];
		while(needed>0)
		{
			if(ind>=N) {return 0;}
			if(mp[ind].ff>i) {return 0;}
			if(mp[ind].ss<i) {ind++; continue;}
			else {needed--; ind++; continue;}
		}
	}
	return 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...