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: medals and cups. Bizon the Champion has a1 first prize cups, a2 second prize cups anda3 third 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 a1a2 and a3 (0 ≤ a1, a2, a3 ≤ 100). The second line contains integers b1b2 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 11 1 14

Output

YES

Input

1 1 32 3 42

Output

YES

Input

1 0 01 0 01

Output

NO
#include <iostream>
#include <cstdio>
using namespace std;

int main()
{
    int a1,a2,a3,b1,b2,b3,n;
    while(scanf("%d%d%d%d%d%d",&a1,&a2,&a3,&b1,&b2,&b3)!=-1)
    {
        cin>>n;
        int a,b,sum;
        sum=0;
        a=a1+a2+a3;
        b=b1+b2+b3;
        if(a%5==0)
        sum+=a/5;
        else
        sum+=a/5+1;
        if(b%10==0)
        sum+=b/10;
        else
        sum+=b/10+1;
        if(sum<=n)
        cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
    return 0;
}
时间: 2024-08-28 14:55:10

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

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

题目链接:http://codeforces.com/contest/448/problem/A ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943/ma

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)——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

Codeforces Round #256 (Div. 2) Multiplication Table

刚刚开始想到一种很暴力但还行的方法,不过在和TK讨论的过程中引出了一个更好的算法 #include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; long long n,m,k; long long check(long long x) { long long ans=0; for(int i=1;i<=n;i++) { ans

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)D 二分答案

D. Multiplication Table time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Bizon the Champion isn't just charming, he also is very smart. While some of us were learning the multiplication tabl

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