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 ...
随机推荐
- python面向对象(二)
属性查找 类有两种属性:数据属性和函数属性 1. 类的数据属性是所有对象共享的 2. 类的函数属性是绑定给对象用的 class BeijingStudent: school='Beijing' ...
- centos7 安装python3.6
•到python官网找到下载路径, 用wget下载 wget https://www.python.org/ftp/python/3.6.4/Python-3.6.4.tgz •解压tgz包 tar ...
- spring 登录提示 Bad credentials
spring 日志输出:Authentication failed: password does not match stored value in spring security 3.2,检查密码发 ...
- django中的django admin插件
一.django admin前言 1.admin的作用 为了方便后台开发者快速的部署测试环境,于是就产生了admin,admin主要是操作models中的类从而实现对数据库中的数据增删改查的操作. 2 ...
- offsetHeight+scrollHeight+clientHeight
ch 窗口可见区域高度 :ch = padding + height(height不是所有内容的高度,是样式定义的高度) oh border以内的内容高度: oh = border + padding ...
- commonAncestor
commonAncestor 光标或选区所在区域最外层的祖先节点
- Loadrunder脚本篇——web_submit_data实现提交post请求
概述 web_link()和web_url()函数都是页面访问型函数,实现HTTP请求中的GET方法,如果需要实现POST方法,可使用web_submit_form或web_submit_data() ...
- python cookboo 文件与IO 函数
写出文本数据 g = open('test.txt', 'rt', newline='',encoding = 'utf-8', errors='replace') t是windows平台特有的所谓t ...
- HASH、HASH函数、HASH算法的通俗理解
之前经常遇到hash函数或者经常用到hash函数,但是hash到底是什么?或者hash函数到底是什么?却很少去考虑.最近同学去面试被问到这个问题,自己看文章也看到hash的问题.遂较为细致的追究了一番 ...
- java中类名.class, class.forName(), getClass()区别
Class对象的生成方式如下: 1.类名.class 说明: JVM将使用类装载器, 将类装入内存(前提是:类还没有装入内存),不做类的初始化工作.返回Class的对象 2.Cla ...