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 题意:一个有向图,每个结点一个非负值,可以转移到其他结点 ...
随机推荐
- 最详细的PHP flush()与ob_flush()的区别详解
buffer ---- flush()buffer是一个内存地址空间,Linux系统默认大小一般为4096(1kb),即一个内存页.主要用于存储速度不同步的设备或者优先级不同的 设备之间传办理数据的区 ...
- xgboost安装指南(win10,win7 64位)
---恢复内容开始--- Win7 64位系统下安装XGBoost 1. 环境介绍 计算机系统:win7 64位 Xgboost版本:xgboost0.6 2. 依赖软件环境 1) python 64 ...
- Quartz源码——JobStore保存JonDetail和Trigger源码分析(一)
我都是分析的jobStore 方式为jdbc的SimpleTrigger!RAM的方式类似分析方式! {0} :表的前缀 ,如表qrtz_trigger ,{0}== qrtz_ {1}:quartz ...
- 初始Socket编程(python)
通信双方要有一个服务端和一个客户端,所以要分开去写代码. 所以我创建了两个py程序,第一个是服务端:iServer.py 和客户端 iClient.py 服务端: #coding:utf-8from ...
- Sequence query 好题啊
Sequence query Time Limit: 2000/1000MS (Java/Others) Memory Limit: 128000/64000KB (Java/Others) Subm ...
- Online Bayesian Probit Regression介绍之Factor Graph
下面就开始讲讲概率图中的Factor Graph.概率图博大精深,非我等鼠辈能够完全掌握,我只是通过研究一些通用的模型,对概率图了解了一点皮毛.其实我只是从概率这头神兽身上盲人摸象地抓掉几根毛,我打算 ...
- 在CentOS6上利用PXE+Kickstart+Apache+DHCP实现无人值守安装
在CentOS6上利用PXE+Kickstart+Apache+DHCP实现无人值守安装 1.PXEServer:OS:CentOS6.9IP:172.16.25.69: (1)apache:# mo ...
- php里的抽象类和接口
//实例化类产生对象.//class fenbi//{// //普通成员,属于对象// public $length = "10cm";// //静态成员,静态变量,属于类.// ...
- MySQL Base
/* 连接与断开服务器 */ mysql -h 地址 -P 端口 -u 用户名 -p 密码 ---> input pwd /* 数据库存贮引擎 */ InnoDB : 1) ...
- Java面向对象 Main函数 静态的应用 单例设计模式
Java面向对象 Main函数 静态的应用与单例设计模式 知识概要 (1)Main函数的细解 (2)静态的应用,静态变量,静态代码块,静态函数 (3)单例设计模式 1.M ...