Max-distance sub-sequence



tải về 32.39 Kb.
Chuyển đổi dữ liệu04.05.2024
Kích32.39 Kb.
#57467
Max-distance Sub-Sequence

MAX-DISTANCE SUB-SEQUENCE

  • Given N elements (2≤ N ≤100,000) on a straight line at positions x1,…, xn (0≤ x ≤1,000,000,000)
  • The distance of a subset of N elements is defined to be the minimum distance between two elements
  • Find the subset of N given elements containing exactly C elements such that the distance is maximal.
  • Input
    • The first line contains a positive integer T (1 <= T <= 20) which is the number of test cases.
    • Subsequent lines are T test cases with the following format:
      • Line 1: Two space-separated integers: N and C
      • Lines 2: contains x1, x2 , . . , xn
  • Output
    • For each test case output one integer: the distance of the subset found.

MAX-DISTANCE SUB-SEQUENCE


stdin

stdout


5 3 




9

3
  • Example

tải về 32.39 Kb.

Chia sẻ với bạn bè của bạn:




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương