codeforces-scrape

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

175A.md (1680B)


      1 Source: https://codeforces.com/problemset/problem/175/A
      2 
      3 A. Robot Bicorn Attack
      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 Vasya plays Robot Bicorn Attack.
     22 
     23 The game consists of three rounds. For each one a non-negative integer amount of points is given. The result of the game is the sum of obtained points. Vasya has already played three rounds and wrote obtained points one by one (without leading zeros) into the string *s*. Vasya decided to brag about his achievement to the friends. However, he has forgotten how many points he got for each round. The only thing he remembers is the string *s*.
     24 
     25 Help Vasya to find out what is the maximum amount of points he could get. Take into account that Vasya played Robot Bicorn Attack for the first time, so he could not get more than 1000000 (106) points for one round.
     26 
     27 Input
     28 
     29 The only line of input contains non-empty string *s* obtained by Vasya. The string consists of digits only. The string length does not exceed 30 characters.
     30 
     31 Output
     32 
     33 Print the only number — the maximum amount of points Vasya could get. If Vasya is wrong and the string could not be obtained according to the rules then output number -1.
     34 
     35 Examples
     36 
     37 Input
     38 
     39 ```
     40 1234
     41 ```
     42 
     43 Output
     44 
     45 ```
     46 37
     47 ```
     48 
     49 Input
     50 
     51 ```
     52 9000
     53 ```
     54 
     55 Output
     56 
     57 ```
     58 90
     59 ```
     60 
     61 Input
     62 
     63 ```
     64 0009
     65 ```
     66 
     67 Output
     68 
     69 ```
     70 -1
     71 ```
     72 
     73 Note
     74 
     75 In the first example the string must be split into numbers 1, 2 and 34.
     76 
     77 In the second example the string must be split into numbers 90, 0 and 0.
     78 
     79 In the third example the string is incorrect, because after splitting the string into 3 numbers number 00 or 09 will be obtained, but numbers cannot have leading zeroes.