This commit is contained in:
2025-07-13 20:15:09 +08:00
parent ed2072aef8
commit ec59538a98
3 changed files with 14230 additions and 0 deletions

11
include/solution/2410.h Normal file
View File

@@ -0,0 +1,11 @@
#ifndef INC_2410_H
#define INC_2410_H
#ifdef __cplusplus
extern "C"
{
#endif
int matchPlayersAndTrainers(int *players, int playersSize, int *trainers, int trainersSize);
#ifdef __cplusplus
}
#endif
#endif

30
src/2410.c Normal file
View File

@@ -0,0 +1,30 @@
#include <solution/2410.h>
#include <stdbool.h>
#include <stdlib.h>
int cmp(const void *a, const void *b)
{
return *(int *)a - *(int *)b;
}
int matchPlayersAndTrainers(int *players, int playersSize, int *trainers, int trainersSize)
{
qsort(trainers, trainersSize, sizeof(int), cmp);
qsort(players, playersSize, sizeof(int), cmp);
int match = 0;
for (int i = 0, j = 0; i < playersSize && j < trainersSize; i++)
{
for (; j < trainersSize; j++)
{
if (trainers[j] >= players[i])
{
match++;
j++;
break;
}
}
}
return match;
}

14189
tests/test_2410.cpp Normal file

File diff suppressed because it is too large Load Diff