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

题意:从第一天的某餐,开始记录,到最后一天的某餐结束,求最少未记录的天数;

思路:找到最大值减一;

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define esp 0.00000000001
const int N=1e5+,M=1e6+,inf=1e9;
ll a[];
int main() {
ll maxx=,ans=;
for(int i=;i<=;i++)
scanf("%lld",&a[i]),maxx=max(maxx,a[i]);
maxx--;
for(int i=;i<=;i++)
{
if(maxx>a[i])
ans+=maxx-a[i];
}
printf("%lld\n",ans);
return ;
}

Codeforces Round #377 (Div. 2) C. Sanatorium 水题的更多相关文章

  1. Codeforces Round #185 (Div. 2) B. Archer 水题

    B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...

  2. Codeforces Round #360 (Div. 2) A. Opponents 水题

    A. Opponents 题目连接: http://www.codeforces.com/contest/688/problem/A Description Arya has n opponents ...

  3. Codeforces Round #190 (Div. 2) 水果俩水题

    后天考试,今天做题,我真佩服自己... 这次又只A俩水题... orz各路神犇... 话说这次模拟题挺多... 半个多小时把前面俩水题做完,然后卡C,和往常一样,题目看懂做不出来... A: 算是模拟 ...

  4. Codeforces Round #256 (Div. 2/A)/Codeforces448A_Rewards(水题)解题报告

    对于这道水题本人觉得应该应用贪心算法来解这道题: 下面就贴出本人的代码吧: #include<cstdio> #include<iostream> using namespac ...

  5. Codeforces Round #340 (Div. 2) B. Chocolate 水题

    B. Chocolate 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co Bob loves everyt ...

  6. Codeforces Round #340 (Div. 2) A. Elephant 水题

    A. Elephant 题目连接: http://www.codeforces.com/contest/617/problem/A Descriptionww.co An elephant decid ...

  7. Codeforces Round #340 (Div. 2) D. Polyline 水题

    D. Polyline 题目连接: http://www.codeforces.com/contest/617/problem/D Descriptionww.co There are three p ...

  8. Codeforces Round #338 (Div. 2) A. Bulbs 水题

    A. Bulbs 题目连接: http://www.codeforces.com/contest/615/problem/A Description Vasya wants to turn on Ch ...

  9. Codeforces Round #282 (Div. 1) A. Treasure 水题

    A. Treasure Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/494/problem/A ...

随机推荐

  1. MAC常用快捷键

    1.F11 用于当前界面与桌面进行切换,Command-M 最小化窗口,Option-Command-M 最小化所有窗口,Command-数字 切换数字指定的网页列表 Shift-Command-D ...

  2. STM32的寄存器控制SDA_IN()/SDA_OUT()

    #define SDA_IN()  {GPIOA->CRL&=0X0FFFFFFF;GPIOA->CRL|=(u32)8<<28;}#define SDA_OUT() ...

  3. ASP开发入门+实战电子书共50本 —下载目录

    小弟为大家整理50个ASP电子书籍,有入门,也有实战电子书,做成了一个下载目录,欢迎大家下载. 资源名称 资源地址 ASP.NET开发实战1200例_第I卷 http://down.51cto.com ...

  4. 日常css和js小知识点记录

    2015-6-29 1.<meta name="viewport" content="width=device-width,user-scalable=no&quo ...

  5. PHP array_count_values() 函数用于统计数组中所有值出现的次数。

    定义和用法 array_count_values() 函数用于统计数组中所有值出现的次数. 本函数返回一个数组,其元素的键名是原数组的值,键值是该值在原数组中出现的次数. 语法 array_count ...

  6. Windows驱动开发(中间层)

    Windows驱动开发 一.前言 依据<Windows内核安全与驱动开发>及MSDN等网络质料进行学习开发. 二.初步环境 1.下载安装WDK7.1.0(WinDDK\7600.16385 ...

  7. move语义和右值引用

    C++11支持move语义,用以避免非必要拷贝和临时对象. 具体内容见收藏中的“C++右值引用” .

  8. python:正则表达式 re

    #re正则的用法:match匹配从开头 search 取一个就回来了,findout取所以匹配的,slit分割 sub替换 #-*- coding:utf8 -*- # Auth:fulimei #r ...

  9. Coco2dx 3D例子

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18     // add "HelloWorld" splash screen"   ...

  10. 【转】MYSQL入门学习之三:全文本搜索

    转载地址:http://www.2cto.com/database/201212/173873.html 一.理解全文本搜索   www.2cto.com   1.MyISAM支持全文本搜索,而Inn ...