Submission #292505

#TimeUsernameProblemLanguageResultExecution timeMemory
292505MonochromaticTeams (IOI15_teams)C++17
34 / 100
4065 ms20088 KiB
#include "teams.h"
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

int n;
vector<int> sweep[100005];
void init(int N, int A[], int B[]){
	n = N;
	for(int i = 0; i < n; i ++)
		sweep[A[i]].push_back(B[i]);
}

int can(int M, int K[]){
	vector<int> cnt(n + 1, 0);
	for(int i = 0; i < M; i ++)
		cnt[K[i]] += K[i];

	priority_queue<int, vector<int>, greater<int> > pq;
	for(int i = 1; i <= n; i ++){
		for(int x : sweep[i]) pq.push(x);
		while(pq.size() && pq.top() < i) pq.pop();
		if(pq.size() < cnt[i]) return 0;
		for(; cnt[i] --; pq.pop());
	}
	return 1;
}

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:24:16: warning: comparison of integer expressions of different signedness: 'std::priority_queue<int, std::vector<int>, std::greater<int> >::size_type' {aka 'long unsigned int'} and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} [-Wsign-compare]
   24 |   if(pq.size() < cnt[i]) 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...