1181B.md (1725B)
1 Source: https://codeforces.com/problemset/problem/1181/B 2 3 B. Split a Number 4 5 time limit per test 6 7 2 seconds 8 9 memory limit per test 10 11 512 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Dima worked all day and wrote down on a long paper strip his favorite number $n$ consisting of $l$ digits. Unfortunately, the strip turned out to be so long that it didn't fit in the Dima's bookshelf. 22 23 To solve the issue, Dima decided to split the strip into two non-empty parts so that each of them contains a positive integer without leading zeros. After that he will compute the sum of the two integers and write it down on a new strip. 24 25 Dima wants the resulting integer to be as small as possible, because it increases the chances that the sum will fit it in the bookshelf. Help Dima decide what is the minimum sum he can obtain. 26 27 Input 28 29 The first line contains a single integer $l$ ($2 \le l \le 100\,000$) — the length of the Dima's favorite number. 30 31 The second line contains the positive integer $n$ initially written on the strip: the Dima's favorite number. 32 33 The integer $n$ consists of exactly $l$ digits and it does not contain leading zeros. Dima guarantees, that there is at least one valid way to split the strip. 34 35 Output 36 37 Print a single integer — the smallest number Dima can obtain. 38 39 Examples 40 41 Input 42 43 ``` 44 7 45 1234567 46 ``` 47 48 Output 49 50 ``` 51 1801 52 ``` 53 54 Input 55 56 ``` 57 3 58 101 59 ``` 60 61 Output 62 63 ``` 64 11 65 ``` 66 67 Note 68 69 In the first example Dima can split the number $1234567$ into integers $1234$ and $567$. Their sum is $1801$. 70 71 In the second example Dima can split the number $101$ into integers $10$ and $1$. Their sum is $11$. Note that it is impossible to split the strip into "1" and "01" since the numbers can't start with zeros.