CodeForces - 907A Masha and Bears
2 seconds
256 megabytes
standard input
standard output
A family consisting of father bear, mother bear and son bear owns three cars. Father bear can climb into the largest car and he likes it. Also, mother bear can climb into the middle car and she likes it. Moreover, son bear can climb into the smallest car and he likes it. It's known that the largest car is strictly larger than the middle car, and the middle car is strictly larger than the smallest car.
Masha came to test these cars. She could climb into all cars, but she liked only the smallest car.
It's known that a character with size a can climb into some car with size b if and only if a ≤ b, he or she likes it if and only if he can climb into this car and 2a ≥ b.
You are given sizes of bears and Masha. Find out some possible integer non-negative sizes of cars.
You are given four integers V1, V2, V3, Vm(1 ≤ Vi ≤ 100) — sizes of father bear, mother bear, son bear and Masha, respectively. It's guaranteed that V1 > V2 > V3.
Output three integers — sizes of father bear's car, mother bear's car and son bear's car, respectively.
If there are multiple possible solutions, print any.
If there is no solution, print "-1" (without quotes).
50 30 10 10
50
30
10
100 50 10 21
-1
In first test case all conditions for cars' sizes are satisfied.
In second test case there is no answer, because Masha should be able to climb into smallest car (so size of smallest car in not less than 21), but son bear should like it, so maximum possible size of it is 20.
分析
水题,但有个坑点,就是Masha只like最小的车,就是说2*Vm<v2。
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#include<queue>
using namespace std;
typedef long long LL;
const int maxn = 1e4+;
const int mod = +;
typedef pair<int,int> pii;
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define ms(a,b) memset(a,b,sizeof(a)) int main(){
// freopen("in.txt","r",stdin);
int v1,v2,v3,vm;
scanf("%d%d%d%d",&v1,&v2,&v3,&vm); if(vm>*v3||v3>*vm||v2<=vm){
cout<<-<<endl;
}else{ cout<<*v1<<endl<<*v2<<endl<<max(v3,vm)<<endl; }
return ;
}
CodeForces - 907A Masha and Bears的更多相关文章
- Masha and Bears(翻译+思维)
Description A family consisting of father bear, mother bear and son bear owns three cars. Father bea ...
- O - Masha and Bears
Problem description A family consisting of father bear, mother bear and son bear owns three cars. Fa ...
- codeforces 653D D. Delivery Bears(二分+网络流)
题目链接: D. Delivery Bears time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- Codeforces 856D - Masha and Cactus(树链剖分优化 dp)
题面传送门 题意: 给你一棵 \(n\) 个顶点的树和 \(m\) 条带权值的附加边 你要选择一些附加边加入原树中使其成为一个仙人掌(每个点最多属于 \(1\) 个简单环) 求你选择的附加边权值之和的 ...
- [Codeforces]856D - Masha and Cactus
题目大意:给出一棵树和若干条可以加入的边,要求加入若干条边使图是仙人掌并且加入的边权和最大,仙人掌定义为没有一个点属于超过1个环.(n,m<=200,000) 做法:这题的仙人掌跟平时见到的不太 ...
- CodeForces 471C MUH and House of Cards
MUH and House of Cards Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & % ...
- Codeforces Round #454 Div. 2 A B C (暂时)
A. Masha and bears 题意 人的体积为\(V\),车的大小为\(size\),人能钻进车的条件是\(V\leq size\),人对车满意的条件是\(2V\geq size\). 现知道 ...
- Codeforces Round #269 (Div. 2) D - MUH and Cube Walls kmp
D - MUH and Cube Walls Time Limit:2000MS Memory Limit:262144KB 64bit IO Format:%I64d & % ...
- Codeforces Round #454
Masha and Bears Tic-Tac-Toe Shockers Seating of Students Party Power Tower Reverses
随机推荐
- APS.NET MVC4生成解析二维码简单Demo
一.视图 @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewpor ...
- WorkStation 虚拟机迁移到 ESXi的后续处理.
自己遇到了然后按照blog http://blog.sina.com.cn/s/blog_79a8b8e10102w8bm.html 解决 特此记录一下. 将Workstation的vmdk文件导入到 ...
- 给定一个 hashMap 最终输出最大值的键
/** * * 类 描 述:机试题: 给定一个 hashMap 最终输出最大值的键 * 作 者: 赵 鹏 * 时 间:2017年7月4日 下午6:51:06 */ public class Test ...
- laravel 在nginx服务器上除了首页其余都是404的问题
nginx对应站点的.conf配置文件添加如下代码 location / { try_files $uri $uri/ /index.php$is_args$query_string; #语法: tr ...
- Jquery 组 checkbox全选按钮
<!DOCTYPE html><html lang="zh-cn"><head> <meta charset="utf-8&qu ...
- (二) 关于配置travis-ci持续集成python pytest测试的相关记录
接上篇 上篇只是非常官方的描述了一下travis-ci是包括了些什么部分会如何工作但是并没有深入介绍也没有写demo. 这里先贴上一个我已经测试好了的python_travis-ci的环境 https ...
- mangTomany 自关联之个人感悟
介绍: 应用场景:评论表 manyTomany 原则上就是一个类 自己建立一个关系表 这个关系表的列 由自己定义 例如 图中 from_userinfo_id() 是人为规定的 男生列 to_use ...
- CF527D
题面 这题还挺水的,把那个式子稍微变形一下就可以的到xi-wi>=xj+wj,易知:若把每个点看做一条线段,左端点是xi-wi,右端点是xi+wi,就只要求最多的不重叠的线段数就可以了,然后就是 ...
- hdu 3397 Sequence operation (线段树 区间合并 多重标记)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=3397 题意: 给你一串01串,有5种操作 0. 区间全部变为0 1.区间全部变为1 2.区间异或 3.询问 ...
- hdu 5919 Sequence II (可持久化线段树)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5919 大致题意: 给你一个长度为n的序列,q个询问,每次询问是给你两个数x,y,经过与上一次的答案进行运算 ...