Sanatorium

CodeForces - 732C

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 bd 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

Input
3 2 1
Output
1
Input
1 0 0
Output
0
Input
1 1 1
Output
0
Input
1000000000000000000 0 1000000000000000000
Output
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的更多相关文章

随机推荐

  1. Java NIO1:浅谈I/O模型

    一.什么是同步?什么是异步? 同步和异步的概念出来已经很久了,网上有关同步和异步的说法也有很多.以下是我个人的理解: 同步就是:如果有多个任务或者事件要发生,这些任务或者事件必须逐个地进行,一个事件或 ...

  2. 在Sublime中配置JsFormat

    JsFormat配置文件: { // exposed jsbeautifier options "indent_with_tabs": false, // 保留换行符 " ...

  3. SkylineGlobe7.0.1版本 主页面如何和Popup里面的嵌入页面相互传值

    不想多说废话,直接看代码吧!(支持IE和Chrome) 主页面: function ShowPanel() { var sg = CreateSGObj(); var pp = sg.Creator. ...

  4. Microsoft Artificial Intelligence Conference(2018.05.21)

    时间:2018.05.21地点:北京嘉丽大酒店

  5. 【原创】研发应该懂的binlog知识(下)

    引言 这篇是<研发应该懂的binlog知识(上)>的下半部分.在本文,我会阐述一下binlog的结构,以及如何使用java来解析binlog. 不过,话说回来,其实严格意义上来说,研发应该 ...

  6. 美团2016秋招笔试B

    1.下述解决死锁的方法中,属于死锁预防策略的是? 资源有序分配法  银行家算法:避免死锁 资源有序分配法:预防死锁 资源分配图化简法:检测死锁 撤销进程法:解决死锁   2. 什么是死锁? 如果一个进 ...

  7. [2018福大至诚软工助教]alpha阶段小结

    [2018福大至诚软工助教]alpha阶段小结 一.得分 1. 冲刺(7次 Scrum) 150分 1)第1篇(25分) 项目 评分标准 各个成员在 Alpha 阶段认领的任务 (6分)视详细程度给分 ...

  8. Mike and strings CodeForces - 798B (简洁写法)

    题目链接 时间复杂度 O(n*n*|s| ) 纯暴力,通过string.substr()函数来构造每一个字符串平移后的字符串. #include <iostream> #include & ...

  9. iOS开发造轮子 | 通用占位图

    https://www.jianshu.com/p/beca3ac24031 实际运用场景: 没网时的提示view,tableView或collectionView没内容时的展示view,以及其它特殊 ...

  10. 福州大学软件工程1816 | W班 第1次作业成绩排名

    1.作业地址 第一次作业--准备篇 2.作业要求 (1)回想一下你初入大学时对计算机专业的畅想 当初你是如何做出选择计算机专业的决定的? 你认为过去两年中接触到的课程是否符合你对计算机专业的期待,为什 ...