Longest increasing pub-sequence
Time limit3sMemory limit1024 MB
Given N integer points, find the longest route whose consecutive Euclidean step lengths strictly increase, with no point repeated back to back.
- Level
Medium6 of 10
- Topics
- Dynamic programming, Sorting, Geometry
- Solved
- No attempts yet
Problem
Elise has just started at Stackköpings Tekniska Högskola (STH), and as part of the freshman welcome there is a traditional pub crawl. A pub crawl means visiting every section room and having a drink at each one. Elise and her friends do not drink alcohol, but they like long walks. So they want to plan a route with as many visits as possible, where the distances they walk between rooms are strictly increasing. Find the maximum number of visits they can make.
The section rooms are points in the plane with integer coordinates. Elise and her friends always walk the shortest distance between two rooms. The distance is the usual Euclidean distance, . They may start at any room. They may visit the same room more than once, and each visit counts separately. However, they may not visit the same place twice in a row.

Starting at and following the red arrows gives a route with visits, which is also the maximum.
Input
The first line contains an integer , the number of section rooms (). Each of the next lines contains two integers , the coordinates of a section room ().
Output
Print one integer, the maximum number of visits Elise and her friends can make when the distances between consecutive rooms are strictly increasing.