Submission #1089991

#TimeUsernameProblemLanguageResultExecution timeMemory
1089991hengliaoTeams (IOI15_teams)C++17
34 / 100
4102 ms41304 KiB
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define pb push_back
#define vll vector<ll>
#define pll pair<ll, ll>
typedef long long ll;

const ll mxN=5e5+5;

ll n, m;
vll adj[mxN];

void init(int N, int a[], int b[]) {
	n=N;
	for(ll i=0;i<n;i++){
		adj[a[i]].pb(b[i]);
	}
}

int can(int M, int k[]) {
	m=M;
	priority_queue<ll, vll, greater<ll>> pq;
	vll cnt(n+1);
	for(ll i=0;i<m;i++){
		cnt[k[i]]+=k[i];
	}
	for(ll i=1;i<=n;i++){
		while(!pq.empty() && pq.top()<i) pq.pop();
		for(auto &it:adj[i]){
			pq.push(it);
		}
		while(cnt[i]--){
			if(pq.empty()) return 0;
			pq.pop();
		}
	}
	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...