CodeForces - 732C Sanatorium

/*
  注意!!!题目的理解很重要,我当初就是因为题意理解有误,一直WA
  
  We shouldn't count as missed meals on the arrival day before Vasiliy's arrival and meals on the departure day after he left.
  这句话表明了:如果在抵达的那天,或者离开的那天,没有吃满3顿,那么这两种少吃的情况,并不算在计算的顿数中
*/

#include <iostream>
typedef long long ll;
using namespace std;
int main()
{
	cin.tie(0);
	cin.sync_with_stdio(false);
	ll b, d, s;
	while (cin >> b >> d >> s)
	{
		ll ans = 0, tp = max(b, max(d, s));
		tp--;
		if (tp > b) ans += tp - b;
		if (tp > d) ans += tp - d;
		if (tp > s) ans += tp - s;
		cout << ans << endl;
	}
	return 0;
}

posted @ 2017-08-31 15:30  mofushaohua  阅读(165)  评论(0编辑  收藏  举报