codeforces-scrape

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

31A.md (1188B)


      1 Source: https://codeforces.com/problemset/problem/31/A
      2 
      3 A. Worms Evolution
      4 
      5 time limit per test
      6 
      7 2 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Professor Vasechkin is studying evolution of worms. Recently he put forward hypotheses that all worms evolve by division. There are *n* forms of worms. Worms of these forms have lengths *a*1, *a*2, ..., *a**n*. To prove his theory, professor needs to find 3 different forms that the length of the first form is equal to sum of lengths of the other two forms. Help him to do this.
     22 
     23 Input
     24 
     25 The first line contains integer *n* (3 ≤ *n* ≤ 100) — amount of worm's forms. The second line contains *n* space-separated integers *a**i* (1 ≤ *a**i* ≤ 1000) — lengths of worms of each form.
     26 
     27 Output
     28 
     29 Output 3 distinct integers *i* *j* *k* (1 ≤ *i*, *j*, *k* ≤ *n*) — such indexes of worm's forms that *a**i* = *a**j* + *a**k*. If there is no such triple, output -1. If there are several solutions, output any of them. It possible that *a**j* = *a**k*.
     30 
     31 Examples
     32 
     33 Input
     34 
     35 ```
     36 5  
     37 1 2 3 5 7
     38 ```
     39 
     40 Output
     41 
     42 ```
     43 3 2 1
     44 ```
     45 
     46 Input
     47 
     48 ```
     49 5  
     50 1 8 1 5 1
     51 ```
     52 
     53 Output
     54 
     55 ```
     56 -1
     57 ```