CodeForces 366A- Dima and Guards
来源:互联网 发布:易语言彩票预测源码 编辑:程序博客网 时间:2024/05/16 22:49
在每个门处有两个守卫,可以通过巧克力棒或者果汁来收买他们,但是他们对这些东西都有一个最低的要求,不能低于这
条线,要不然是收买不动的,这个人想通过n元收买他们,输入有四行,每一行的a,b,c,d表示这两个门卫分别对两个物品可以接受的最小价值,如果可以收买的话,按照输入的顺序输出第一组方案,输出的东西包括输入的行数的下标,下标从一开始
,然后是第一个人可以接受的最小值,最后是剩下多少给第二个人买东西,不存在方案的话输出-1,输出第一组。
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int a[10],b[10],c[10],d[10];int main(){int n;while(scanf("%d",&n)!=EOF){int i,j;int ans=-1,anx,any;for(i=0;i<4;i++){scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);int xx=min(a[i],b[i]);int yy=min(c[i],d[i]);if(xx+yy<=n){if(ans==-1){anx=xx;any=n-xx;ans=i+1;}}}if(ans!=-1){printf("%d %d %d\n",ans,anx,any);}elseprintf("-1\n");}return 0;}
1 0
- 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【水】
- 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】
- 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 (暑期小练习)
- 设计模式--装饰者模式
- hdu1698 Just a Hook 线段树延迟标记区间更新 求加权区间总和
- java使用POI的导入导出
- 笔记 - Java 进制和位运算
- 关于大型网站技术演进的思考(四)--存储的瓶颈(4)
- CodeForces 366A- Dima and Guards
- http通讯协议详解
- EasyUI的load,reload,loadData
- SharedPreferences
- FZU 2124 FOJ 2124 吃豆人【BFS】
- 关于大型网站技术演进的思考(三)--存储的瓶颈(3)
- codeforces 489B
- 在centos上搭建svn服务器
- Shiro入门9:Shiro授权流程和三种授权方式和权限标识符规则