#P5425. [USACO19OPEN] I Would Walk 500 Miles G
[USACO19OPEN] I Would Walk 500 Miles G
Description
Farmer John wants to divide his cows numbered () into non-empty groups (), such that any two cows from different groups must walk some distance to meet each other. Cows and (where ) are willing to walk miles in order to meet.
Given a grouping plan that divides the cows into non-empty groups, let be the minimum number of miles that any two cows from different groups are willing to walk to meet. To test the cows' loyalty to each other, Farmer John wants to divide the cows into groups in the best possible way so that is as large as possible.
Input Format
The input consists of a single line containing and , separated by a space.
Output Format
Output the optimal value of .
3 2
2019201769
Hint
In this example, cow and cow are willing to walk miles to meet. Cow and cow are willing to walk miles. Cow and cow are willing to walk miles. Therefore, if cow is put alone in one group, and cows and are put into another group, then (this is the best result we can achieve in this problem).
Translated by ChatGPT 5
京公网安备 11011102002149号