D - Zhenya moves from the dormitory URAL - 2015
Input
Output
Example
input | output |
---|---|
10000 50 70 |
You should rent the apartment #1 alone. |
30000 0 1 |
You should rent the apartment #3 with the friend #1. |
1000 0 0 |
Forget about apartments. Live in the dormitory. |
Notes
Hint
/*
* @Author: lyuc
* @Date: 2017-04-30 15:11:54
* @Last Modified by: lyuc
* @Last Modified time: 2017-04-30 15:32:17
*/
/**
* 题意:Zhenya想租房子,可以和朋友合租,也可以自己租,自己租的时候要付全部的租金,和朋友合租的时候要严格的
* 一人一半
*
* 思路:暴力,读错题了,应该是自己住的单间的时候快乐值是:快乐值1+酒店快乐值,自己住双人间的时候快乐值是:
* 快乐值2+酒店快乐值,和朋友合租的时候快乐值是:朋友的快乐值+酒店快乐值
*/
#include <iostream>
#include <stdio.h>
using namespace std;
struct Fr{
int pay,hap;
}fr[];
struct Ho{
int id,pay,hap;
}ho[];
int pay,hap1,hap2;
int n,m;
int main(){
// freopen("in.txt","r",stdin);
scanf("%d%d%d",&pay,&hap1,&hap2);
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d%d",&fr[i].pay,&fr[i].hap);
}
scanf("%d",&m);
for(int i=;i<m;i++){
scanf("%d%d%d",&ho[i].id,&ho[i].pay,&ho[i].hap);
}
int maxhap=-;
int maxho=-;
int maxfr=-;
for(int i=;i<m;i++){
if(ho[i].id==){
if(pay>=ho[i].pay){
if(hap1+ho[i].hap>maxhap){
maxhap=hap1+ho[i].hap;
maxho=i;
maxfr=-;
}
}
}else if(ho[i].id==){
if(pay>=ho[i].pay){
if(hap2+ho[i].hap>maxhap){
maxhap=hap2+ho[i].hap;
maxho=i;
maxfr=-;
}
}
for(int j=;j<n;j++){
if(min(pay,fr[j].pay)*>=ho[i].pay){
if(fr[j].hap+ho[i].hap>maxhap){
maxhap=fr[j].hap+ho[i].hap;
maxho=i;
maxfr=j;
}
}
}
}
}
if(maxho==-){
puts("Forget about apartments. Live in the dormitory.");
}else{
if(maxfr==-){
printf("You should rent the apartment #%d alone.\n",maxho+);
}else{
printf("You should rent the apartment #%d with the friend #%d.\n",maxho+,maxfr+);
}
}
return ;
}
D - Zhenya moves from the dormitory URAL - 2015的更多相关文章
- ural 2015 Zhenya moves from the dormitory(模拟)
2015. Zhenya moves from the dormitory Time limit: 1.0 secondMemory limit: 64 MB After moving from hi ...
- Gym 100507D Zhenya moves from the dormitory (模拟)
Zhenya moves from the dormitory 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/D Descrip ...
- ural 2014 Zhenya moves from parents
2014. Zhenya moves from parents Time limit: 1.0 secondMemory limit: 64 MB Zhenya moved from his pare ...
- Gym 100507C Zhenya moves from parents (线段树)
Zhenya moves from parents 题目链接: http://acm.hust.edu.cn/vjudge/contest/126546#problem/C Description Z ...
- ural2014 Zhenya moves from parents
Zhenya moves from parents Time limit: 1.0 secondMemory limit: 64 MB Zhenya moved from his parents’ h ...
- URAL 2014 Zhenya moves from parents --线段树
题意:儿子身无分文出去玩,只带了一张他爸的信用卡,当他自己现金不足的时候就会用信用卡支付,然后儿子还会挣钱,挣到的钱都是现金,也就是说他如果有现金就会先花现金,但是有了现金他不会还信用卡的钱.他每花一 ...
- zhenya moves from parents
Zhenya moved from his parents' home to study in other city. He didn't take any cash with him, he onl ...
- 【线段树】Gym - 100507C - Zhenya moves from parents
线段树每个结点维护两个值,分别是这个区间的 负债 和 余钱. 按时间顺序从前往后看的时候,显然负债是单调不减的. 按时间顺序从后往前看的时候,显然余钱也是单调不减的,因为之前如果有余钱,可能会增加现在 ...
- NEERC 2014, Eastern subregional contest
最近做的一场比赛,把自己负责过的题目记一下好了. Problem B URAL 2013 Neither shaken nor stirred 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...
随机推荐
- webpack + vue + node 打造单页面(入门篇)
1.node下载地址:http://nodejs.cn/download/,安装完成检查node和npm版本 2.淘宝镜像 : npm install cnpm -g --registry=https ...
- 翻译连载 | 第 9 章:递归(下)-《JavaScript轻量级函数式编程》 |《你不知道的JS》姊妹篇
原文地址:Functional-Light-JS 原文作者:Kyle Simpson-<You-Dont-Know-JS>作者 关于译者:这是一个流淌着沪江血液的纯粹工程:认真,是 HTM ...
- php调用webservice接口
项目中使用到了调用三方厂商webService接口.他的接口类似为http://haha.cn:86/BaseInfoService.svc?wsdl,在这里我注意到了"wsdl" ...
- CANVAS模仿龙卷风特效
大学时候,有一段时间对flash比较感兴趣.去图书馆借了一本很厚很厚的falsh书籍. 翻了几页之后,就再没有往后看过.印象比较深的是作者说他用flash完成了一个龙卷风效果. 一直到现在我也没有看到 ...
- SAP Gateway简介
SAP Gateway在S4/HANA时代的ABAP开发模型中有着重要的地位.SAP Gateway是什么?它对ABAP开发有怎样的影响?可以为我们提供哪些方便?这篇译文将浅要地讨论这些话题. SAP ...
- Vue.js的从入门到放弃进击录(二)
哇塞,昨晚更新的篇(一)这么多阅读量,看来入坑的人越来越多啦~熬了一个礼拜夜,今天终于生病惹~国庆要肥家咯·所以把篇(二)也更完.希望各位入坑的小伙伴能少跳几个坑呗.如果有什么不对的地方也欢迎讨论指正 ...
- 51 nod 1097 拼成最小的数 思路:字符串排序
题目: 思路:1.以字符串输入这些整数. 2.对这些字符串排序,排序规则为尽量让能让结果变小的靠前. 代码中有注释,不懂的欢迎在博客中评论问我. 代码: #include <bits\stdc+ ...
- 记一次Java的内存泄露分析
当前环境 jdk == 1.8 httpasyncclient == 4.1.3 代码地址 git 地址:https://github.com/jasonGeng88/java-network-pro ...
- 数据的分类-JavaScript数据类型
JavaScript数据类型 1.数据类型是什么? 我们接触的绝大多数程序语言来说,把数据都进行了分类,包括数字.字符.逻辑真假:int,long,string,boolean....等等:我们都知道 ...
- ch3-form(get/post) $.ajax(get/post)
1 http(get)请求 提交的数据 用req.query接收 1.1 router.get() //http(get)请求方式 1.2 接收http(get)方式提交的数据 req.query 方 ...