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 ...
随机推荐
- 转载的shell命令73条
1.检查远程端口是否对bash开放: echo >/dev/tcp/8.8.8.8/53 && echo "open" 2.让进程转入后台: Ctrl + z ...
- MySQL复制(一):复制的基本步骤
从这里开始,对复制的内容开始做一些详细的描述,复制从简单到入门 复制最简单的模式如下 基本的三个简单步骤 1 配置一个服务器为master 2 配置一个服务器为slave 3 将slave连接到mas ...
- 数据库之MySQL(四)
数据库中的范式: 第一范式(1NF): 数据表中的每一列(字段),必须是不可拆分的最小单元,也就是确保每一列的原子性. 例如: userInfo: '山东省烟台市 1318162008' 依照第一范式 ...
- ubuntu安装deb文件
install the deb-package, e.g. using the Terminal command$ sudo apt install <path-to-smartgit-deb- ...
- Python基础-高阶函数
1.高阶函数变量可以指向函数函数的参数可以接收变量一个函数可以接收另一个函数作为参数 def f(n): return n * n def fansik(a, b, func): return fun ...
- python 文件格式为 txt 转换成 csv 格式
1 txt 文件的读取 open(file, mode='r', buffering=-1, encoding=None, errors=None, newline=None, closefd=Tr ...
- mysql终结篇
一.mysql中not null unique和primary key 的区别 1.not null unique 是给一个字段设置非空且唯一的特性,当表中字段没有设置primary key的主键特性 ...
- python基础25 -----python高级用法
一.Event 1.为什么会有Event? 线程的一个关键特性就是每个线程的运行都是独立运行且状态不可预测.如果程序中的线程需要通过别的线程的状态来判断自己线程中的 某个程序是否需要执行,那么Even ...
- pycharm一直scanning files to index
删除了c盘的垃圾文件之后,pycharm就一直scanning files to index 解决方法: 点击file,然后选择invalidate caches / restart ...,再弹出的 ...
- Linux Shell基础 read命令
read命令 read 命令用于接收标准输入(键盘)的输入,或者其他文件描述符的输入.得到输入后,read 命令将数据放入一个标准变量中,read 命令格式如下: [root@localhost ~] ...