Submission #131394

#TimeUsernameProblemLanguageResultExecution timeMemory
131394antimirageTeams (IOI15_teams)C++14
34 / 100
4006 ms10744 KiB
#include "teams.h"
#include <bits/stdc++.h>

#define fr first
#define sc second

using namespace std;

const int N = 1e5 + 5;

int cn[N], n;

pair <int, int> a[N];

void init(int N, int l[], int r[]) {
	n = N;
	for (int i = 0; i < n; i++) {
		a[i] = {l[i], r[i]};
	}
	sort(a, a + n);
}

int can(int m, int k[]) {
	sort(k, k + m);
	int j = 0;
	priority_queue <int> q;
	
	for (int i = 0; i < m; i++) {
		
		int cn = k[i];
		while (j < n && a[j].fr <= k[i]) {
			q.push(-a[j].sc);
			j++;
		}
		while (!q.empty() && cn > 0) {
			if (-q.top() >= k[i]) cn--;
			q.pop();
		}
		if (cn > 0)
			return false;
	}
	return true;
}

Compilation message (stderr)

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:15:34: warning: declaration of 'N' shadows a global declaration [-Wshadow]
 void init(int N, int l[], int r[]) {
                                  ^
teams.cpp:9:11: note: shadowed declaration is here
 const int N = 1e5 + 5;
           ^
teams.cpp: In function 'int can(int, int*)':
teams.cpp:30:7: warning: declaration of 'cn' shadows a global declaration [-Wshadow]
   int cn = k[i];
       ^~
teams.cpp:11:5: note: shadowed declaration is here
 int cn[N], n;
     ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...