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\n",ans);
    }
    return 0;
}

时间: 2024-10-16 22:14:58

CodeForces 369A Valera and Plates( 水)的相关文章

codeforces A. Valera and Plates 题解

Valera is a lazy student. He has m clean bowls and k clean plates. Valera has made an eating plan for the next n days. As Valera is lazy, he will eat exactly one dish per day. At that, in order to eat a dish, he needs exactly one clean plate or bowl.

CodeForces 22C System Administrator 小水怡情 图论+构造

题目链接:点击打开链接 构造一个星形图+一个完全图就好了.. #include <cstdio> #include <cstring> #include <algorithm> #include <vector> #include <iostream> #include <map> #include <set> #include <math.h> using namespace std; #define inf

Codeforces A. Valera and X 题解

判断二维字符串是否满足下面条件: on both diagonals of the square paper all letters are the same; all other squares of the paper (they are not on the diagonals) contain the same letter that is different from the letters on the diagonals. Help Valera, write the progra

CodeForces 707A Brain&#39;s Photos (水题)

题意:给一张照片的像素,让你来确定是黑白的还是彩色的. 析:很简单么,如果有一种颜色不是黑白灰,那么就一定是彩色的. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #i

Codeforces 444C DZY Loves Colors 水线段树

题目链接:点击打开链接 水.. #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <math.h> #include <set> #include <vector> #include <map> using namespace std; #define ll long long #defi

Codeforces 441C Valera and Tubes

题目链接:Codeforces 441C Valera and Tubes 没看到r >= 2一直错.让前几个管子占用2个格子.最后一个把剩下的都占用了.假设问题有解.这样做一定有解.其它策略就不一定了(比方让某个管子占用了3个格子.而总共同拥有四个格子,两个管子). #include <iostream> #include <cstdio> using namespace std; int main() { int n, m, k; scanf("%d%d%d&q

Codeforces gym 100685 C. Cinderella 水题

C. CinderellaTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100685/problem/C Description Cinderella is given a task by her Stepmother before she is allowed to go to the Ball. There are N (1 ≤ N ≤ 1000) bottles with water in th

codeforces 710A A. King Moves(水题)

题目链接: A. King Moves 题意: 给出king的位置,问有几个可移动的位置; 思路: 水题,没有思路; AC代码: #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <bits/stdc++.h> #include <stack> #include &l

codeforces 696A Lorenzo Von Matterhorn 水题

这题一眼看就是水题,map随便计 然后我之所以发这个题解,是因为我用了log2()这个函数判断在哪一层 我只能说我真是太傻逼了,这个函数以前听人说有精度问题,还慢,为了图快用的,没想到被坑惨了,以后尽量不用 #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <iostream> #include <algorithm> #