https://ac.nowcoder.com/acm/contest/8925/A

根据题意易的出菜一份份的买的OK,并且是越贵的菜越先买,如果一开始最贵的菜就买不了,那就是不行

#include <iostream>
#include <algorithm>

using namespace std;
int main() {
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n,m;
        scanf("%d%d",&n,&m);
        int a[n],i;
        for(i=0;i<n;i++)
        scanf("%d",&a[i]);
        sort(a,a+n);
        double x=m;
        for(i=n-1;i>=0;i--)
        {
            if(a[i]-x>0)
            break;
            else {
                x = x-0.7*a[i];
            }
        }
        if(i==-1)
        printf("yes\n");
        else printf("no\n");


    }
    return 0;
}

B https://ac.nowcoder.com/acm/contest/9033/B

#include <algorithm> 
#include <cmath>
using namespace std;

int main()
{
    int n,i;
    scanf("%d",&n);
    int a[n],flag=0;
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    int sum =1;
    for(i=0;i<n-1;i++)
    {
        if(a[i]==0)
        {
            if(a[i+1]==1)
            {
                sum++;i++;
            }
        }

    }
    printf("%d",sum);
    return 0;
}