好斗的牛
You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.
好斗的奶牛
题目描述
在一排牛棚中,每个牛棚中关着奶牛,可是奶牛有点好斗,如果相邻的牛棚都有奶牛,就容易打架。农场主就会在两个牛棚之间加一个隔板,如果没有相邻就不会打架。现在需要你帮忙计算一下需要加多少个隔板才能防止奶牛打架。
输入格式
第一行一个正整数 ,表示奶牛的头数。
接下来 行,每行一个正整数,代表奶牛关的牛棚编号。保证牛棚的编号是从小到大的,并且没有重复。当然有些牛棚并没有关奶牛
输出格式
一行一个整数,表示隔板的数量。
样例 #1
样例输入 #1
5
1 2 3 4 5
样例输出 #1
4
别惹奶牛
- Status
- Done
- Rule
- ACM/ICPC
- Problem
- 3
- Start at
- 2024-6-1 12:00
- End at
- 2024-12-18 12:00
- Duration
- 4800 hour(s)
- Host
- Partic.
- 44