Submission #301791

#TimeUsernameProblemLanguageResultExecution timeMemory
301791square1001Teams (IOI15_teams)C++14
34 / 100
4046 ms40096 KiB
#include "teams.h"
#include <queue>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
int N; vector<int> A, B; vector<vector<int> > G;
void init(int N_, int A_[], int B_[]) {
	N = N_;
	A = vector<int>(A_, A_ + N);
	B = vector<int>(B_, B_ + N);
	G = vector<vector<int> >(N + 1);
	for(int i = 0; i < N; ++i) {
		G[A[i]].push_back(B[i]);
	}
}
int can(int M, int K[]) {
	sort(K, K + M);
	int ptr = 0;
	priority_queue<int, vector<int>, greater<int> > que;
	for(int i = 0; i < M; ++i) {
		while(ptr <= K[i]) {
			for(int j : G[ptr]) {
				que.push(j);
			}
			++ptr;
		}
		while(!que.empty() && que.top() < K[i]) {
			que.pop();
		}
		if(que.size() < K[i]) {
			return 0;
		}
		for(int j = 0; j < K[i]; ++j) {
			que.pop();
		}
	}
	return 1;
}

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:31:17: 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 'int' [-Wsign-compare]
   31 |   if(que.size() < K[i]) {
      |      ~~~~~~~~~~~^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...