306202: CF1163A. Eating Soup
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Eating Soup
题意翻译
有一个长度为$n$的环,求删除$m$个点后剩余连通块数最大值题目描述
The three friends, Kuro, Shiro, and Katie, met up again! It's time for a party... What the cats do when they unite? Right, they have a party. Since they wanted to have as much fun as possible, they invited all their friends. Now $ n $ cats are at the party, sitting in a circle and eating soup. The rules are simple: anyone having finished their soup leaves the circle. Katie suddenly notices that whenever a cat leaves, the place where she was sitting becomes an empty space, which means the circle is divided into smaller continuous groups of cats sitting next to each other. At the moment Katie observes, there are $ m $ cats who left the circle. This raises a question for Katie: what is the maximum possible number of groups the circle is divided into at the moment? Could you help her with this curiosity? You can see the examples and their descriptions with pictures in the "Note" section.输入输出格式
输入格式
The only line contains two integers $ n $ and $ m $ ( $ 2 \leq n \leq 1000 $ , $ 0 \leq m \leq n $ ) — the initial number of cats at the party and the number of cats who left the circle at the moment Katie observes, respectively.
输出格式
Print a single integer — the maximum number of groups of cats at the moment Katie observes.
输入输出样例
输入样例 #1
7 4
输出样例 #1
3
输入样例 #2
6 2
输出样例 #2
2
输入样例 #3
3 0
输出样例 #3
1
输入样例 #4
2 2
输出样例 #4
0