codeforces732C
Sanatorium
Vasiliy spent his vacation in a sanatorium, came back and found that he completely forgot details of his vacation!
Every day there was a breakfast, a dinner and a supper in a dining room of the sanatorium (of course, in this order). The only thing that Vasiliy has now is a card from the dining room contaning notes how many times he had a breakfast, a dinner and a supper (thus, the card contains three integers). Vasiliy could sometimes have missed some meal, for example, he could have had a breakfast and a supper, but a dinner, or, probably, at some days he haven't been at the dining room at all.
Vasiliy doesn't remember what was the time of the day when he arrived to sanatorium (before breakfast, before dinner, before supper or after supper), and the time when he left it (before breakfast, before dinner, before supper or after supper). So he considers any of these options. After Vasiliy arrived to the sanatorium, he was there all the time until he left. Please note, that it's possible that Vasiliy left the sanatorium on the same day he arrived.
According to the notes in the card, help Vasiliy determine the minimum number of meals in the dining room that he could have missed. We shouldn't count as missed meals on the arrival day before Vasiliy's arrival and meals on the departure day after he left.
Input
The only line contains three integers b, d and s (0 ≤ b, d, s ≤ 1018, b + d + s ≥ 1) — the number of breakfasts, dinners and suppers which Vasiliy had during his vacation in the sanatorium.
Output
Print single integer — the minimum possible number of meals which Vasiliy could have missed during his vacation.
Examples
3 2 1
1
1 0 0
0
1 1 1
0
1000000000000000000 0 1000000000000000000
999999999999999999
Note
In the first sample, Vasiliy could have missed one supper, for example, in case he have arrived before breakfast, have been in the sanatorium for two days (including the day of arrival) and then have left after breakfast on the third day.
In the second sample, Vasiliy could have arrived before breakfast, have had it, and immediately have left the sanatorium, not missing any meal.
In the third sample, Vasiliy could have been in the sanatorium for one day, not missing any meal.
sol:小学奥数题,找到最多的那个,一个个减过去即可
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
inline ll read()
{
ll s=;
bool f=;
char ch=' ';
while(!isdigit(ch))
{
f|=(ch=='-'); ch=getchar();
}
while(isdigit(ch))
{
s=(s<<)+(s<<)+(ch^); ch=getchar();
}
return (f)?(-s):(s);
}
#define R(x) x=read()
inline void write(ll x)
{
if(x<)
{
putchar('-'); x=-x;
}
if(x<)
{
putchar(x+''); return;
}
write(x/);
putchar((x%)+'');
return;
}
#define W(x) write(x),putchar(' ')
#define Wl(x) write(x),putchar('\n')
ll a,b,c;
int main()
{
R(a) ;R(b); R(c);
ll Max=max(max(a,b),c),ans=;
if(a<Max) ans+=Max-a-;
if(b<Max) ans+=Max-b-;
if(c<Max) ans+=Max-c-;
Wl(ans);
return ;
}
/*
input
3 2 1
output
1 Input
1 0 0
Output
0 Input
1 1 1
Output
0 Input
1000000000000000000 0 1000000000000000000
Output
999999999999999999
*/
codeforces732C的更多相关文章
随机推荐
- 【Codeforces 212E】Restaurants
Codeforces 212 E 题意:给一棵树,其中删去一个点,剩余的联通块们同一个联通块都得涂同一个颜色(黑或白),问黑色涂的个数有可能是哪些. 思路:肯定是背包. 假设现在删掉\(u\)这个节点 ...
- 百度地图JSAPI浏览器定位
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=你的秘钥 ...
- java基础 容器 API
- JMX,Jstatd做好JVM应用上线的最后一层保障
目录 我理解的监控 代码异常监控 远程主机配置jmx 修改要启动的java程序启动参数(JVM_OPTS). 修改文件权限 启动jvisualvm 监控服务器上的java程序 jstatd 连接到远程 ...
- 一次linux服务器黑客入侵后处理
场景: 周一上班centos服务器ssh不可用,web和数据库等应用不响应.好在vnc可以登录 使用last命令查询,2号之前的登录信息已被清空,并且sshd文件在周六晚上被修改,周日晚上2点服务器 ...
- react虚拟dom diff算法
react虚拟dom:依据diff算法 前端:更新状态.更新视图:所以前端页面的性能问题主要是由Dom操作引起的,解放Dom操作复杂性 刻不容缓 因为:Dom渲染慢,而JS解析编译相对非常非常非常快! ...
- [2018福大至诚软工助教]UML设计小结
[2018福大至诚软工助教]UML设计小结 一.得分 总分(50分) 团队信息 (4分) 队名 (1分) 团队成员的学号与姓名(需要标注队长)(1分) 本次作业的博客链接(1分) 三者完全,4分 团队 ...
- shell脚本--CGI获取请求数据(GET / POST)
Case 1: 获取地址栏传递的参数(即通过GET方式) CGI的环境变量中有个QUERY_STRING,可以获取地址栏传递的参数,该参数可以是手动加上的,也可以是通过表单的get方式提交的,比如下面 ...
- [转帖]Windows批处理(cmd/bat)常用命令小结
Windows批处理(cmd/bat)常用命令小结 非常值得学习的文档 先放这里 有时间做实验, 转载自:“趣IT”微信公共号 前言 批处理文件(batch file)包含一系列 DOS命令,通常用于 ...
- [2018.05].NET Core 3 and Support for Windows Desktop Applications
.NET Core 3 and Support for Windows Desktop Applications Richard 微软官网的内容...net 3.0 升级任务 任重道远 https:/ ...