Submission #1089302

#TimeUsernameProblemLanguageResultExecution timeMemory
1089302PanosPaskTeams (IOI15_teams)C++14
34 / 100
4051 ms19048 KiB
#include <bits/stdc++.h>
#include "teams.h"

using namespace std;

typedef pair<int, int> pi;

int N;
vector<pi> students;

void init(int n, int A[], int B[])
{
	N = n;
	students.resize(N);

	for (int i = 0; i < N; i++) {
		students[i] = {A[i], B[i]};
	}

	sort(students.begin(), students.end());
}

int can(int M, int K[])
{
	sort(K, K + M);

	int p = 0;
	priority_queue<int, vector<int>, greater<int>> q;

	for (int i = 0; i < M; i++) {
		while (p < N && students[p].first <= K[i]) {
			q.push(students[p].second);
			p++;
		}

		while (!q.empty() && q.top() < K[i]) {
			q.pop();
		}

		for (int j = 0; j < K[i]; j++) {
			if (q.empty()) {
				return 0;
			}
			q.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...