#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
/* 降順 */
int cmp(const void* x, const void* y) {
int a = *(const int*)x, b = *(const int*)y;
return a > b ? -1 : a < b;
}
int N;
int64_t X, Y;
int A[212345];
int B[212345];
int main(void) {
int i;
int ans1, ans2;
int64_t sum;
if (scanf("%d%d%d", &N, &X, &Y) != 3) return 1;
for (i = 0; i < N; i++) {
if (scanf("%d", &A[i]) != 1) return 1;
}
for (i = 0; i < N; i++) {
if (scanf("%d", &B[i]) != 1) return 1;
}
qsort(A, N, sizeof(*A), cmp);
qsort(B, N, sizeof(*B), cmp);
ans1 = ans2 = N;
sum = 0;
for (i = 0; i < N; i++) {
sum += A[i];
if (sum > X) {
ans1 = i + 1;
break;
}
}
sum = 0;
for (i = 0; i < N; i++) {
sum += B[i];
if (sum > Y) {
ans2 = i + 1;
break;
}
}
printf("%d\n", ans1 <= ans2 ? ans1 : ans2);
return 0;
}
Main.c: In function ‘main’:
Main.c:20:23: warning: format ‘%d’ expects argument of type ‘int *’, but argument 3 has type ‘int64_t *’ {aka ‘long int *’} [-Wformat=]
20 | if (scanf("%d%d%d", &N, &X, &Y) != 3) return 1;
| ~^ ~~
| | |
| int * int64_t * {aka long int *}
| %ld
Main.c:20:25: warning: format ‘%d’ expects argument of type ‘int *’, but argument 4 has type ‘int64_t *’ {aka ‘long int *’} [-Wformat=]
20 | if (scanf("%d%d%d", &N, &X, &Y) != 3) return 1;
| ~^ ~~
| | |
| int * int64_t * {aka long int *}
| %ld