This page is still under construction.

Parts of this page are still being built. What you see may change.

Crane Balancing

Time limit1sMemory limit128 MB

Summary
Find the range of extra weight at the first vertex that keeps the polygon balanced on the x-axis.
Level

Medium6 of 10

Topics
Geometry, Math
Solved
No attempts yet

Problem

A crane cross section is a polygon resting on the xx-axis. Each 1×11 \times 1 unit of area weighs 1 kg.

Extra weight is attached at the first polygon vertex. Find the range of attachable weight (in kg) for which the crane does not topple left or right. Print ⌊a⌋..⌈b⌉\lfloor a \rfloor .. \lceil b \rceil for range [a,b][a,b], or ⌊a⌋..inf\lfloor a \rfloor .. inf for [a,∞)[a,\infty). Print unstable if no weight works.

Input

  • nn (3≤n≤1003 \le n \le 100): number of vertices.
  • Next nn lines: xi,yix_i, y_i. Weight attaches at the first vertex; at least two vertices have y=0y=0.

Output

Stable weight range, or unstable.

Examples5

  1. Example 1

    Input
    7
    50 50
    0 50
    0 0
    30 0
    30 30
    40 40
    50 40
    
    Expected output
    0 .. 1017
    
  2. Example 2

    Input
    4
    10 10
    0 10
    0 0
    20 0
    
    Expected output
    0 .. inf
    
  3. Example 3

    Input
    5
    18 36
    0 36
    0 0
    23 0
    63 57
    
    Expected output
    138 .. inf
    
  4. Example 4

    Input
    4
    21 25
    0 25
    0 0
    31 0
    
    Expected output
    0 .. inf
    
  5. Example 5

    Input
    5
    79 28
    0 28
    0 0
    31 0
    77 60
    
    Expected output
    57 .. 576