[Solution] Empty Graph Codeforces Solution
positive integers fell down on you from the skies, along with a positive integer .
You can apply the following operation at most times:
- Choose an index and an integer . Then do (assign to ).
Then build a complete undirected weighted graph with vertices numbered with integers from to , where edge () has weight .
You have to find the maximum possible diameter of the resulting graph after performing at most operations.
The diameter of a graph is equal to , where is the length of the shortest path between vertex and vertex .
Each test contains multiple test cases. The first line contains the number of test cases ().
Description of the test cases follows.
The first line of each test case contains two integers and (, ).
The second line of each test case contains positive integers ().
It is guaranteed that the sum of over all test cases does not exceed .
For each test case print one integer — the maximum possible diameter of the graph after performing at most operations.
No comments:
Post a Comment