제출 #780493

#제출 시각아이디문제언어결과실행 시간메모리
780493dozerTeams (IOI15_teams)C++14
0 / 100
4081 ms10776 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]];
		//cout<<a[i]<<sp<<b[i]<<endl;
	}
}

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

컴파일 시 표준 에러 (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;
      |     ^
teams.cpp: In function 'int can(int, int*)':
teams.cpp:32:11: warning: declaration of 'i' shadows a previous local [-Wshadow]
   32 |  for (int i = 0; i < M; i++){
      |           ^
teams.cpp:30:6: note: shadowed declaration is here
   30 |  int i = 0, j = 0;
      |      ^
teams.cpp:34:12: warning: declaration of 'j' shadows a previous local [-Wshadow]
   34 |   for (int j = 0; j < n && curr > 0; j++){
      |            ^
teams.cpp:30:13: note: shadowed declaration is here
   30 |  int i = 0, j = 0;
      |             ^
teams.cpp:30:6: warning: unused variable 'i' [-Wunused-variable]
   30 |  int i = 0, j = 0;
      |      ^
teams.cpp:30:13: warning: unused variable 'j' [-Wunused-variable]
   30 |  int i = 0, j = 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...