Submission #121728

#TimeUsernameProblemLanguageResultExecution timeMemory
121728nvmdavaTeams (IOI15_teams)C++17
34 / 100
4022 ms19600 KiB
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;

vector<pair<int, int> > ls;

void init(int N, int A[], int B[]) {
	for(int i = 0; i < N; i++){
		ls.push_back({A[i], B[i]});
	}
	sort(ls.begin(), ls.end(), [](pair<int, int>& lhs, pair<int, int>& rhs){
		if(lhs.second == rhs.second)
			return lhs.first > rhs.first;
		return lhs.second > rhs.second;
	});
}

int can(int M, int K[]) {
	sort(K + 0, K + M, [](int& lhs ,int &rhs){
		return lhs > rhs;
	});
	int it = 0;
	priority_queue<int> pq;
	for(int i = 0; i < M; i++){
		while(it != ls.size() && ls[it].second >= K[i]){
			pq.push(ls[it++].first);
		}
		while(!pq.empty() && pq.top() > K[i]) pq.pop();
		while(K[i]--){
			if(pq.empty()) return 0;
			pq.pop();
		}
	}
	return 1;
	
}

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:25:12: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while(it != ls.size() && ls[it].second >= 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...