Submission #780485

#TimeUsernameProblemLanguageResultExecution timeMemory
780485vjudge1Teams (IOI15_teams)C++17
0 / 100
4027 ms18040 KiB
#include "teams.h"
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
#define sp " "
#define pii pair<int, int>


int a[500005], b[500005], n;

void init(int N, int A[], int B[]) {
	n = N;
	vector<int> v(N);
	iota(v.begin(), v.end(), 0);
	sort(v.begin(), v.end(), [&](int a, int b){
		if (B[a] == B[b]) return A[a] < B[a];
		return B[a] < B[b];
	});
	for (int i = 0; i < N; i++)
		a[i] = A[v[i]], b[i] = B[v[i]];
}

int can(int M, int K[]) {
	int i = 0, j = 0;
	while(i < n && j < M){
		int curr = K[j];
		while(i < n && b[i] < curr) i++;
		if (i == n) return 0;
		while(curr > 0 && i < n && a[i] <= K[j]) i++, curr--;
		if (curr > 0) return 0;
		j++;
	}
	return 1;
}

Compilation message (stderr)

teams.cpp: In lambda function:
teams.cpp:17:42: warning: declaration of 'b' shadows a global declaration [-Wshadow]
   17 |  sort(v.begin(), v.end(), [&](int a, int b){
      |                                      ~~~~^
teams.cpp:11:16: note: shadowed declaration is here
   11 | int a[500005], b[500005], n;
      |                ^
teams.cpp:17:35: warning: declaration of 'a' shadows a global declaration [-Wshadow]
   17 |  sort(v.begin(), v.end(), [&](int a, int b){
      |                               ~~~~^
teams.cpp:11:5: note: shadowed declaration is here
   11 | int a[500005], b[500005], 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...