不知道为什么,洛谷给的输出数据和我自己测试的输出数据有的能对上有的对不上,
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int main()
{
int n, s, sum = 0;
int a, b;
scanf("%d %d", &n, &s);
scanf("%d %d", &a, &b);
int* x;
int i;
x = (int*)malloc(n * sizeof(int));
if (x == NULL) {
return 1;
}
int* y;
y = (int*)malloc(n * sizeof(int));
if (y == NULL) {
return 1;
}
for (i = 0; i < n; i++)
{
scanf("%d %d", &x[i], &y[i]);
}
for (i = 0; i < n; i++)
{
if (a + b >= x[i] && s>=y[i] )
{
sum++;
s = s - y[i];
if (s < 0)
{
break;
}
}
}
printf("%d", sum);
free(x);
free(y);
return 0;
}