codeforces 732C - Sanatorium
来源:互联网 发布:在线app打包网站源码 编辑:程序博客网 时间:2024/06/05 16:08
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.
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.
Print single integer — the minimum possible number of meals which Vasiliy could have missed during his vacation.
AC代码:
# include <iostream># include <algorithm> using namespace std;typedef long long int ll;int main(){ ll a, b, c; cin >> a >> b >> c;ll m = max(a, max(b, c));ll ans = 0;if (a < m) ans += m - 1 - a;if (b < m) ans += m - 1 - b;if (c < m) ans += m - 1 - c;cout << ans << endl;return 0;}
- [codeforces 732C]Sanatorium
- codeforces 732C - Sanatorium
- Codeforces 732C-Sanatorium
- CodeForces 732C Sanatorium
- CodeForces 732C Sanatorium
- 【43.26%】【codeforces 732C】Sanatorium
- CodeForces 732C 之 Sanatorium
- codeforces 732C Sanatorium(数学题)
- 【codeforces 732C】 Sanatorium【乱搞题 数学题】
- CodeForces-732C-Sanatorium(模拟)
- CodeForces 732 C.Sanatorium(水~)
- 【codeforces 723C C. Sanatorium】
- 732C. Sanatorium
- Sanatorium Codeforces Round#377-C(逻辑)
- Codeforces Round #377 (Div. 2) C. Sanatorium
- Codeforces Round #377 (Div. 2) C Sanatorium
- C. Sanatorium
- Codeforces Round #377 (Div. 2) C. Sanatorium 分类讨论
- oj题之分数序列
- Swift - 字典闹出来的笑话
- 多任务深度学习
- LightOJ-1034-tarjan
- c++::关于引用
- codeforces 732C - Sanatorium
- Human-level concept learning through probabilistic program induction文章总结
- Android样式的开发(三):layer-list篇
- Android布局之LinearLayout
- uploadify 插件
- linux之mini2440内核移植
- Yii 数据库重连告别General error: 2006 MySQL server has gone away
- [Zenject]Installers学习笔记
- SpringMVC和Spring struts