CodeForces 369A Valera and Plates( 水)

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int bowl,plate;
int n;
int dish[1100];
int main()
{
    int i,j;
    while(scanf("%d%d%d",&n,&bowl,&plate)!=EOF)
    {
        int ans=0;
        for(i=1;i<=n;i++)
        {
            scanf("%d",&dish[i]);
        }
        for(i=1;i<=n;i++)
        {
            if(dish[i]==1)
            {
                if(bowl>0)
                {
                    bowl--;
                }
                else if(bowl==0)
                {
                    ans++;
                }
            }
            else if(dish[i]==2)
            {
                if(plate>0)
                {
                    plate--;
                }
                else if(bowl>0)
                {
                    bowl--;
                }
                else
                {
                    ans++;
                }
            }
        }
        printf("%d
",ans);
    }
    return 0;
}
View Code
原文地址:https://www.cnblogs.com/sola1994/p/4180754.html