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 namespace std;

int main()
{
    double a[10],b[10],suma=0,sumb=0;
    int n,i,j;
    for(i=0; i<3; i++)
    {
        cin>>a[i];
        suma+=a[i];
    }
    for(i=0; i<3; i++)
    {
        cin>>b[i];
        sumb+=b[i];
    }
    cin>>n;
    suma=ceil(suma/5);
    sumb=ceil(sumb/10);
    if(suma+sumb>n)
        cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

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

原文地址:https://www.cnblogs.com/zhchoutai/p/8849669.html

时间: 2024-11-08 16:48:46

Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)的相关文章

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 #344 (Div. 2) C. Report 水题

#include<bits/stdc++.h> #define REP(i,a,b) for(int i=a;i<=b;i++) #define MS0(a) memset(a,0,sizeof(a)) #define rep(i,a,b) for(int i=a;i>=b;i--) #define RI(x) scanf("%d",&x) #define RII(x,y) scanf("%d%d",&x,&y) #d

Codeforces Round #196 (Div. 2) A. Puzzles 水题

A. Puzzles Time Limit: 2 Sec  Memory Limit: 60 MB 题目连接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5373 Description The end of the school year is near and Ms. Manana, the teacher, will soon have to say goodbye to a yet another class. S

Codeforces Round #279 (Div. 2) B - Queue 水题

#include<iostream> #include<mem.h> using namespace std; int p[1000001],q[1000001]; int main() { int n,x,y; memset(q,0,sizeof(q)); cin>>n; while(n) { cin>>x>>y; p[x]=y; q[x]++; q[y]--; n--;//p[x]表示在x之后两位的数是什么 //q[x]表示x这个数究竟有多少

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