#P2988. [USACO10MAR] Test Taking S
[USACO10MAR] Test Taking S
题目描述
Farmer John has to take his annual farming license test. The test has () true/false questions. After last year's poor performance, Bessie wants to help him.
Bessie knows that the number of questions whose answer is 'true' is one of (; ). She has no information about which particular questions are true. Using only this information, she wants to know the best score Farmer John can always guarantee, even without knowing any individual answers.
Example: For and possible counts , if FJ answers 'false' on every question, then if the true count is he gets correct, and if it is he gets correct. So he can guarantee at least correct.
By contrast, if FJ answers 'true' on exactly questions and 'false' on the other , then if the true count is he gets correct, but if the true count is he could get as few as correct (if he guessed 'true' on the that are actually 'false'). So this strategy does not guarantee any correct answers.
Given Bessie's information, compute the maximum number of answers FJ can always get correct if he uses an optimal strategy.
Constraints: , , .
输入格式
- Line 1: Two space-separated integers and .
- Lines : Line contains a single integer .
输出格式
- Line 1: A single integer, the best score FJ is guaranteed to achieve.
6 2
0
3
3
提示
Translation provided by @fan404.
Translated by ChatGPT 5