codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

849B.md (1699B)


      1 Source: https://codeforces.com/problemset/problem/849/B
      2 
      3 B. Tell Your World
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 Connect the countless points with lines, till we reach the faraway yonder.
     22 
     23 There are *n* points on a coordinate plane, the *i*-th of which being (*i*, *y**i*).
     24 
     25 Determine whether it's possible to draw two parallel and non-overlapping lines, such that every point in the set lies on exactly one of them, and each of them passes through at least one point in the set.
     26 
     27 Input
     28 
     29 The first line of input contains a positive integer *n* (3 ≤ *n* ≤ 1 000) — the number of points.
     30 
     31 The second line contains *n* space-separated integers *y*1, *y*2, ..., *y**n* ( - 109 ≤ *y**i* ≤ 109) — the vertical coordinates of each point.
     32 
     33 Output
     34 
     35 Output "Yes" (without quotes) if it's possible to fulfill the requirements, and "No" otherwise.
     36 
     37 You can print each letter in any case (upper or lower).
     38 
     39 Examples
     40 
     41 Input
     42 
     43 ```
     44 5  
     45 7 5 8 6 9
     46 ```
     47 
     48 Output
     49 
     50 ```
     51 Yes
     52 ```
     53 
     54 Input
     55 
     56 ```
     57 5  
     58 -1 -2 0 0 -5
     59 ```
     60 
     61 Output
     62 
     63 ```
     64 No
     65 ```
     66 
     67 Input
     68 
     69 ```
     70 5  
     71 5 4 3 2 1
     72 ```
     73 
     74 Output
     75 
     76 ```
     77 No
     78 ```
     79 
     80 Input
     81 
     82 ```
     83 5  
     84 1000000000 0 0 0 0
     85 ```
     86 
     87 Output
     88 
     89 ```
     90 Yes
     91 ```
     92 
     93 Note
     94 
     95 In the first example, there are five points: (1, 7), (2, 5), (3, 8), (4, 6) and (5, 9). It's possible to draw a line that passes through points 1, 3, 5, and another one that passes through points 2, 4 and is parallel to the first one.
     96 
     97 In the second example, while it's possible to draw two lines that cover all points, they cannot be made parallel.
     98 
     99 In the third example, it's impossible to satisfy both requirements at the same time.