Submission #386644

#TimeUsernameProblemLanguageResultExecution timeMemory
386644alishahali1382Teams (IOI15_teams)C++14
34 / 100
4089 ms12308 KiB
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<#x<<", "<<#y<<"="<<x<<", "<<y<<"\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define all(x) x.begin(), x.end()
#define pb push_back

const int MAXN=500010, SQ=320;

int n, m, k, x, y;
int A[MAXN], B[MAXN], C[MAXN];
priority_queue<int, vector<int>, greater<int>> pq;

void init(int nn, int AA[], int BB[]){
	n=nn;
	vector<pii> vec;
	for (int i=0; i<n; i++) vec.pb({AA[i], BB[i]});
	sort(all(vec));
	for (int i=0; i<n; i++) A[i+1]=vec[i].first, B[i+1]=vec[i].second;
}
bool SolveBig(){
	while (pq.size()) pq.pop();
	int j=1;
	for (int i=0; i<m; i++){
		while (j<=n && A[j]<=C[i]) pq.push(B[j++]);
		while (pq.size() && pq.top()<C[i]) pq.pop();
		int t=C[i];
		if (pq.size()<t) return 0;
		while (t--) pq.pop();
	}
	return 1;
}

int can(int mm, int CC[]) {
	m=mm;
	for (int i=0; i<m; i++) C[i]=CC[i];
	sort(C, C+m);
	return SolveBig();
}

Compilation message (stderr)

teams.cpp: In function 'bool SolveBig()':
teams.cpp:33: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 'int' [-Wsign-compare]
   33 |   if (pq.size()<t) 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...