Submission #384499

#TimeUsernameProblemLanguageResultExecution timeMemory
384499luciocfTeams (IOI15_teams)C++14
34 / 100
4078 ms10220 KiB
#include <bits/stdc++.h>
#include "teams.h"

#define ff first
#define ss second

using namespace std;

typedef pair<int, int> pii;

const int maxn = 1e5+10;

int n;
pii range[maxn];

void init(int N, int A[], int B[])
{
	n = N;
	for (int i = 1; i <= n; i++)
		range[i] = {A[i-1], B[i-1]};

	sort(range+1, range+n+1);
}

int can(int M, int K[])
{
	int m = M;

	vector<int> V;
	for (int i = 0; i < m; i++)
		V.push_back(K[i]);

	sort(V.begin(), V.end());

	multiset<int> st;

	int ptr = 1;

	for (auto qtd: V)
	{
		while (ptr <= n && range[ptr].ff <= qtd)
			st.insert(range[ptr++].ss);

		if (st.size() < qtd) return 0;

		int aux = 0;
		for (auto it = st.begin(); aux < qtd && it != st.end(); it = st.erase(it))
			if (*it >= qtd)
				aux++;

		if (aux < qtd) return 0;
	}

	return 1;
}

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:44:17: warning: comparison of integer expressions of different signedness: 'std::multiset<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   44 |   if (st.size() < qtd) return 0;
      |       ~~~~~~~~~~^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...