ural 2015 Zhenya moves from the dormitory(模拟)
2015. Zhenya moves from the dormitory
Memory limit: 64 MB
Input
Output
Samples
| 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
Problem Source: NEERC 2014, Eastern subregional contest
All submissions (3048) All accepted submissions (740) Solutions rating (524)
#include <bits/stdc++.h>
using namespace std;
int alonecost,alone1value,alone2value;
int friendcost[],friendvalue[],friendnum; int main ()
{
int n;
while(~scanf("%d%d%d",&alonecost,&alone1value,&alone2value))
{
scanf("%d",&friendnum);
for(int i=; i<=friendnum; i++)
scanf("%d%d",&friendcost[i],&friendvalue[i]);
scanf("%d",&n);
int resnum=-,resval=-,resfrinum,resalOrdou;
int alOrdou,cost,value;
for(int i=; i<=n; i++)
{
scanf("%d%d%d",&alOrdou,&cost,&value);
if(cost<=alonecost)///自己住
{
// cout<<"====\n";
if(alOrdou== && value+alone1value > resval)
{
// cout<<"PPPPPPP\n";
resnum=i,resval=value+alone1value,resalOrdou=,resfrinum=-;
}
else if(alOrdou== && value+alone2value > resval)
{
resnum=i,resval=value+alone2value,resalOrdou=,resfrinum=-;
}
}
if(alOrdou== && alonecost>=(cost+)/)
{
//cout<<"++++++++\n";
for(int j=; j<=friendnum; j++)
{
if(friendcost[j]>=(cost+)/ && friendvalue[j]+value>resval)
{
resnum=i,resval=friendvalue[j]+value,resfrinum=j,resalOrdou=;
}
}
}
}
if(resnum==-)
{
printf("Forget about apartments. Live in the dormitory.\n");
}
else
{
printf("You should rent the apartment #%d ",resnum);
if(resalOrdou==)
{
printf("with the friend #%d.\n",resfrinum);
}else{
printf("alone.\n");
}
}
//cout<<resval<<endl;
}
return ;
}
ural 2015 Zhenya moves from the dormitory(模拟)的更多相关文章
- 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 ...
- D - Zhenya moves from the dormitory URAL - 2015
After moving from his parents’ place Zhenya has been living in the University dormitory for a month. ...
- URAL 2014 Zhenya moves from parents --线段树
题意:儿子身无分文出去玩,只带了一张他爸的信用卡,当他自己现金不足的时候就会用信用卡支付,然后儿子还会挣钱,挣到的钱都是现金,也就是说他如果有现金就会先花现金,但是有了现金他不会还信用卡的钱.他每花一 ...
- 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 ...
- c# JD快速搜索工具,2015分析JD搜索报文,模拟请求搜索数据,快速定位宝贝排行位置。
分析JD搜索报文 搜索关键字 女装 第二页,分2次加载. rt=1&stop=1&click=&psort=&page=3http://search.jd.com/Se ...
- 2015 多校联赛 ——HDU5319(模拟)
Painter Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
- 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 ...
随机推荐
- Docker介绍及优缺点对比分析
1.什么是Docker Docker最初是dotCloud公司创始人Solomon Hykes在法国期间发起的一个公司内部项目,于2013年3月以Apache 2.0授权协议开源,主要项目代码在Git ...
- mac安装yarn , MAC升级Nodejs
Npm i -g yarn 第一步,先查看本机node.js版本: `$ node -v` 第二步,清除node.js的cache: `$ sudo npm cache clean -f` 第三步,安 ...
- dom树改变监听
function unwrap(el, target) { if ( !target ) { target = el.parentNode; } while (el.firstChild) { tar ...
- $Android去除系统默认的标题栏和全屏的三种方法
在做应用的时候,很多时候是不需要系统自带的标题栏的,而是自己去实现标题栏,这就要去掉系统的标题栏,下面总结了三种方法.全屏也是一样的道理,也总结了实现的三种方法. (一)去除标题栏 1.方法1 在Ac ...
- 微信小程序相关资料整理
微信小程序官方介绍https://mp.weixin.qq.com/debug/wxadoc/introduction/index.html?t=201818 微信小程序开发资源https://jue ...
- RHEL(或CentOS)中关于逻辑卷( Logical Volume Manager,LVM)的一些概念及使用LVM的例子
1.逻辑卷(logical volumes,LV) 卷管理在物理存储之上的抽象层,它使你能够创建逻辑存储卷.和直接使用物理存储相比,这从很多方面提供了更大的灵活性.比如,使用逻辑卷,你将不再受物理磁盘 ...
- Android 电容屏驱动
Android 电容屏(一):电容屏基本原理篇 Android 电容屏(二):驱动调试之基本概念篇 Android 电容屏(三):驱动调试之驱动程序分析篇
- Django组件 用户认证,form
auth模块 在进行用户登陆验证的时候,如果是自己写代码,就必须要先查询数据库,看用户输入的用户名是否存在于数据库中: 如果用户存在于数据库中,然后再验证用户输入的密码,这样一来就要自己编写大量的代码 ...
- PHP实现链式操作
什么是链式操作 我们经常会在一些应用框架中看到如下代码: $db = new Database; $db->where('cid = 9')->order('aid desc')-> ...
- Android系统--Binder系统具体框架分析(一)补充
Android系统--Binder系统具体框架分析(一)补充 补充:对Binder驱动分析一的代码补充,添加saygoobye和saygoodbye_to服务 test_server.h #ifnde ...