Submission #431868

#TimeUsernameProblemLanguageResultExecution timeMemory
431868frodakcin팀들 (IOI15_teams)C++11
34 / 100
4034 ms20976 KiB
#include "teams.h"
#include <cstring>
#include <algorithm>
#include <numeric>
#include <queue>
#include <vector>
#include <functional>

const int MN = 5e5+10;
const int MQ = 2e5+10;

int N, A[MN], B[MN], ord[MN];

void init(int N, int A[], int B[]) {
	::N=N;
	memcpy(::A, A, N*sizeof*A);
	memcpy(::B, B, N*sizeof*B);
	std::iota(ord, ord+N, 0);
	std::sort(ord, ord+N, [&](int u, int v){return A[u]<A[v];});
}

int can(int M, int K[]) {
	std::sort(K, K+M);
	std::priority_queue<int, std::vector<int>, std::greater<int> > q;
	int n=0;
	for(int i=0;i<M;++i)
	{
		for(;n < N && A[ord[n]] <= K[i];++n)
			q.push(B[ord[n]]);
		for(;!q.empty() && q.top() < K[i];)
			q.pop();
		for(int j=0;j<K[i];++j)
			if(q.empty()) return 0;
			else
				q.pop();
	}
	return 1;
}

Compilation message (stderr)

teams.cpp: In function 'void init(int, int*, int*)':
teams.cpp:14:31: warning: declaration of 'B' shadows a global declaration [-Wshadow]
   14 | void init(int N, int A[], int B[]) {
      |                           ~~~~^~~
teams.cpp:12:15: note: shadowed declaration is here
   12 | int N, A[MN], B[MN], ord[MN];
      |               ^
teams.cpp:14:22: warning: declaration of 'A' shadows a global declaration [-Wshadow]
   14 | void init(int N, int A[], int B[]) {
      |                  ~~~~^~~
teams.cpp:12:8: note: shadowed declaration is here
   12 | int N, A[MN], B[MN], ord[MN];
      |        ^
teams.cpp:14:15: warning: declaration of 'N' shadows a global declaration [-Wshadow]
   14 | void init(int N, int A[], int B[]) {
      |           ~~~~^
teams.cpp:12:5: note: shadowed declaration is here
   12 | int N, A[MN], B[MN], ord[MN];
      |     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...