为什么只有20分?是不是我想太简单了。。。

P1478 陶陶摘苹果(升级版)

Willis_Wong @ 2019-09-28 21:16:09

#include<stdio.h>
#include<math.h>
int n, score, i, a, s, x[5000], b, y[5000], h;
int main()
{
    scanf("%d %d", &n, &s);
    scanf("%d %d", &a, &b);
    for (i = 1; i <= n; i++)
    {
        scanf("%d %d", &x[i], &y[i]);
    }
    h = a + b;
    for (i = 1; i <= n; i++)
    {
        if (h >= x[i])
        {
            if (s >= y[i])
            {
                score++;
                s -= y[i];
                if (s <= 0)
                {
                    break;
                }
            }
        }
    }
    printf("%d", score);
}

by s_ShotღMaki @ 2019-09-28 21:20:24

码风比我好看


by Endless2002 @ 2019-12-15 19:07:08

我和你的差不多,不知道哪错了,看题解更懵了


|