C. Sanatorium
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stack> using namespace std;
typedef long long int LL;
LL b,d,s;
LL max(LL a,LL b)
{
if(a>=b)
return a;
return b;
}
int main()
{
LL ans=0;
scanf("%lld%lld%lld",&b,&d,&s);
if(max(b,max(d,s))==b)
{
ans=max(0,b-s-1)+max(0,b-d-1); }
else if(max(b,max(d,s))==s)
{
ans=max(0,s-b-1)+max(0,s-d-1);
}
else
{
ans=max(0,d-b-1)+max(0,d-s-1);
}
printf("%lld\n",ans);
return 0;
}



CodeForces 732C Sanatorium的更多相关文章

  1. CodeForces 732C Sanatorium (if-else)

    题意:某人去旅游,记录了一共吃了多少顿饭,早中晚,但是有可能缺少,问你最少缺少了多少顿. 析:每把三个数排序,然后再一一对比,肯定是以最大数为主,其他两个肯定是缺少了. 代码如下: #pragma c ...

  2. 【43.26%】【codeforces 732C】Sanatorium

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. Codeforces Round #377 (Div. 2)A,B,C,D【二分】

    PS:这一场真的是上分场,只要手速快就行.然而在自己做的时候不用翻译软件,看题非常吃力非常慢,还有给队友讲D题如何判断的时候又犯了一个毛病,一定要心平气和,比赛也要保证,不要用翻译软件做题: Code ...

  4. codeforces732C

    Sanatorium CodeForces - 732C Vasiliy spent his vacation in a sanatorium, came back and found that he ...

  5. Codeforces Round #377 (Div. 2) C. Sanatorium 水题

    C. Sanatorium time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  6. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  7. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  8. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  9. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

随机推荐

  1. 【HDU 2586】LCA模板

    在一棵树上 求2个点的最短距离.那么首先利用LCA找到2个点的近期公共祖先 公式:ans = dis(x) + dis(y) - 2 * dis(lca(x,y)) 这里的dis(x)指的上x距离根节 ...

  2. 华为OJ训练之 简易的银行排号叫号系统

    闯关第五关的题目,一个中级题和一个高级题.中间题比較简单,半个小时完毕了.题目例如以下 实现一个简易的银行排号叫号系统 get    取号                     演示样例:" ...

  3. iOS_5_汤姆猫

    终于效果图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcHJlX2VtaW5lbnQ=/font/5a6L5L2T/fontsize/400/fill ...

  4. Nginx 使用中文URL,中文目录路径

    Nginx 使用中文URL,中文目录路径 分类: linux2012-05-03 11:04 2672人阅读 评论(0) 收藏 举报 nginxurl服务器translationcentosserve ...

  5. (2)FluidMoveBehavior 之单击 Grid 中 Tile 进行排序

    在上一篇文章中,使用 FluidMoveBehavior 结合 FluidMoveSetTagBehavior 可以使数据从 ListBox 中的 数据显示时,产生缓慢的动画,从而更加生动.其实 Fl ...

  6. Hystrix的用法

    package com.example.demo; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; imp ...

  7. Fast RDP Brute暴力破解3389口令

    http://www.tuicool.com/articles/b67rQfr 下载地址:https://www.rekings.com/fast-rdp-brute-gui-v2-0/

  8. EasyUI Ajax 表单

    创建form <divstyle="width:230px;background:#E0ECFF;padding:10px;">     <formid=&quo ...

  9. 察看下列JSP内容

    察看下列JSP内容 <html><body> <% for (int i=0;i<3;i++){ %> out.print(i*2); <% } %&g ...

  10. php -- 设计模式 之 单例模式

    实现单例的条件:三私一公 三私:私有化构造方法:不让外部创建对象 私有化克隆方法:不让外部克隆对象 私有静态属性:保存已经产生的对象 一公:公共静态方法:在类内部创建对象 实例: <?php / ...