CF366A Dima and Guards
来源:互联网 发布:如何设计装修淘宝店铺 编辑:程序博客网 时间:2024/05/22 01:57
题目大意:Dima要恰好花N元来买两件礼物分别送给四个guardpost中的其中一个的两名guard。
因为题目已经说了:如果有多种情况,输出其中任意一组即可。所以直接拿两名guard要求的两个最低价中最小的相加,再判断其和与N的关系就行了!
#include<stdio.h>#include<algorithm>using namespace std;int main() { int n,a,b,c,d; while(~scanf("%d",&n)){ int num=0;//记录符合条件的guardpost的编号 int first,second;//分别记录送给两guard的礼物要花的钱 for(int i=1;i<=4;i++){ scanf("%d%d%d%d",&a,&b,&c,&d); if(min(a,b)+min(c,d)<=n){//两组中都取最小值判断即可 first=min(a,b); second=n-first;//恰好花N元 num=i;}} if(num) printf("%d %d %d\n",num,first,second); else printf("-1\n");}return 0;}
0 0
- CF366A Dima and Guards
- A. Dima and Guards
- codeforce Dima and Guards
- dima and guards
- Dima and Guards
- Codeforces Dima and Guards
- Dima and Guards
- Dima and Guards
- Dima and Guards
- Dima and Guards
- 【codeforces】Dima and Guards
- codeforce-【A. Dima and Guards】
- CodeForces 366A - Dima and Guards
- CodeForces 366A Dima and Guards
- CodeForces - 366A Dima and Guards
- CodeForces 366A- Dima and Guards
- Codeforces 366A Dima and Guards 【水题】
- CodeForces 366A:Dima and Guards【水】
- Elasticsearch索引管理
- 机器学习算法3——朴素贝叶斯
- Linux认识与简单操作
- EasyAR尝鲜系列教程之视频播放功能的实现
- pcDuino day2
- CF366A Dima and Guards
- LightOJ 1282 Leading and Trailing
- 15个必须知道的chrome开发者技巧
- 多进程和多线程的应用场景
- SQL Server CONVERT() 函数
- bzoj1042: [HAOI2008]硬币购物
- 第1个python程序:打印
- 前端工程师必须收藏的 JavaScript 资源大全
- OPenfire简介