Optimal Subset
Problem description. You are given a convex polygon of n vertices P1, P2, ..., Pn (in counter-clock or clock order). Each vertex is assigned with a weight wi. Find a subset of vertices that includes vertex 1. 1 = i1 2 k ≤ n that maximizes ratio: (dist(i1, i2) + dist(i2, i3) + ... + dist(ik, i1)) / (wi1 + wi2 + ... + wik). Where dist(i, j) refers to Euclidean distance between two points Pi, Pj
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start