Codeforces Round #256 (Div. 2) A. Rewards(简单题)

题目链接:http://codeforces.com/contest/448/problem/A

----------------------------------------------------------------------------------------------------------------------------------------------------------
欢迎光临天资小屋http://user.qzone.qq.com/593830943/main

----------------------------------------------------------------------------------------------------------------------------------------------------------

A. Rewards

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Bizon the Champion is called the Champion for a reason.

Bizon the Champion has recently got a present — a new glass cupboard with n shelves and he decided to put all his presents there. All the presents can be
divided into two types: medals and cups. Bizon the Champion has a1 first
prize cups, a2 second
prize cups and a3third
prize cups. Besides, he has b1 first
prize medals, b2 second
prize medals and b3 third
prize medals.

Naturally, the rewards in the cupboard must look good, that‘s why Bizon the Champion decided to follow the rules:

  • any shelf cannot contain both cups and medals at the same time;
  • no shelf can contain more than five cups;
  • no shelf can have more than ten medals.

Help Bizon the Champion find out if we can put all the rewards so that all the conditions are fulfilled.

Input

The first line contains integers a1, a2 and a3 (0?≤?a1,?a2,?a3?≤?100).
The second line contains integers b1, b2 and b3 (0?≤?b1,?b2,?b3?≤?100).
The third line contains integer n (1?≤?n?≤?100).

The numbers in the lines are separated by single spaces.

Output

Print "YES" (without the quotes) if all the rewards can be put on the shelves in the described manner. Otherwise, print "NO"
(without the quotes).

Sample test(s)

input

1 1 1
1 1 1
4

output

YES

input

1 1 3
2 3 4
2

output

YES

input

1 0 0
1 0 0
1

output

NO

代码如下:

#include <stdio.h>
int main()
{
    int n, a[4],b[4];
    int sum1,sum2;
    int t1,t2;
    while(scanf("%d%d%d",&a[1],&a[2],&a[3])!=EOF)
    {
        sum1=sum2=0;
        sum1+=a[1],sum1+=a[2],sum1+=a[3];
        scanf("%d%d%d",&b[1],&b[2],&b[3]);
        sum2+=b[1],sum2+=b[2],sum2+=b[3];
        scanf("%d",&n);
        if(sum1%5 != 0)
        {
            t1 = sum1/5+1;
        }
        else
            t1 = sum1/5;
        if(sum2%10 != 0)
        {
            t2 = sum2/10+1;
        }
        else
            t2 = sum2/10;
        if(t1+t2 <= n)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}
时间: 2024-10-08 20:15:48

Codeforces Round #256 (Div. 2) A. Rewards(简单题)的相关文章

Codeforces Round #256 (Div. 2) A Rewards

A. Rewards Bizon the Champion is called the Champion for a reason. Bizon the Champion has recently got a present — a new glass cupboard with n shelves and he decided to put all his presents there. All the presents can be divided into two types: medal

Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)

解题报告 意思就是说有n行柜子,放奖杯和奖牌.要求每行柜子要么全是奖杯要么全是奖牌,并且奖杯每行最多5个,奖牌最多10个. 直接把奖杯奖牌各自累加,分别出5和10,向上取整和N比較 #include <iostream> #include <cstdio> #include <cstring> #include <stdlib.h> #include <algorithm> #include <cmath> using namespa

Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告

对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: 1 #include<cstdio> 2 #include<iostream> 3 using namespace std; 4 5 int a[3],b[3]; 6 7 int main(void) 8 { 9 int n; 10 int need = 0; 11 int sum1 = 0,sum2 = 0; 12 for(int i=1;i<=3;++i){ 13 scanf("%d&q

Codeforces Round #256 (Div. 2) A/B/C/D

A. Rewards 水题 #include<cstdio> #include<iostream> #include<cstring> using namespace std; int main() { int a1,a2,a3,b1,b2,b3,s,t1,t2,sum1,sum2; while(scanf("%d%d%d",&a1,&a2,&a3)!=EOF) { scanf("%d%d%d",&

Codeforces Round #256 (Div. 2)

泛泛解: D:求K大,如果我们二分枚举,如果有O(N)的方法统计,就OK了,先枚举,我们对每一行的统计能够达到O(1),所以很简单了. E:有思路,但是代码能了太弱了,DFS学得太水. 我们发现其实就是一个深度递归结构,只有100000个元素,所以这是一个突破点. 先求出所有因子,然后枚举因子,出现的话深度遍历,结束条件是达到第K层或者因子是1,注意:K大于100000时,要变为100000,因为不可能层数大于100000: C:分治+贪心. 这道真是好题,题解的思路是:对区间(L,R)的点贪心

Codeforces Round #256 (Div. 2) B (448B) Suffix Structures

题意就是将第一个字符串转化为第二个字符串,支持两个操作,一个是删除,一个是更换字符位置. 简单的字符串操作!! AC代码如下: #include<iostream> #include<cstring> #include<cstdio> #include<algorithm> #define M 50010 #define inf 100000000 using namespace std; char a[1005],b[1005]; int la,lb; b

Codeforces Round #256 (Div. 2)——Painting Fence

题目连接 题意: n个木条,输入n个木条的高度,每个木条的宽度均为1.现在有长宽均为1的刷子,每次可以选择横着刷或者竖着刷,每次刷的时候不能离开木条,问将所有木条均涂色至少需要刷几次.(刷的时候可以经过已经被刷过的地方) n (1?≤?n?≤?5000),1?≤?ai(高度)?≤?109 分析: 分析一下横着和竖着的关系:假设现在已经有一个操作集合S是答案,那么集合中的操作顺序是可以改变的,即横和竖的顺序可以改变(因为可以经过已经涂色的木条),那么不妨先横着涂色.对于当前[l,r]的区间,答案不

Codeforces Round #256 (Div. 2/B)/Codeforces448B_Suffix Structures(字符串处理)

解题报告 四种情况相应以下四组数据. 给两字符串,推断第一个字符串是怎么变到第二个字符串. automaton 去掉随意字符后成功转换 array 改变随意两字符后成功转换 再者是两个都有和两个都没有 #include <iostream> #include <cstdio> #include <cstring> #include <stdlib.h> #include <algorithm> #include <cmath> usi

Codeforces Round #256 (Div. 2/C)/Codeforces448C_Painting Fence(分治)

解题报告 给篱笆上色,要求步骤最少,篱笆怎么上色应该懂吧,,,刷子可以在横着和竖着刷,不能跳着刷,,, 如果是竖着刷,应当是篱笆的条数,横着刷的话,就是刷完最短木板的长度,再接着考虑没有刷的木板,,, 递归调用,,, #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #define inf 999999999999999 using namespace