All submissions for this problem are available.
Non-Carry sum of two integers is defined as the sum which is obtained when the numbers are added in a fashion in which the carry obtained while previous sum calculation is dropped. For example the Non-Carry sum of 5625 and 8924 is 3549.
5625 + 8924 _____ 3549
as the carry obtained by adding 6 and 9 at the hundreds place is ignored, so is the carry obtained at thousands place is ignored.
Given an array of N integers, A1, A2 ... AN. Find out the Non-Carry sum of two numbers Ai and Aj such that the Non-Carry sum is maximum and i is not equal to j.
First line contains a single integer N, the number of elements in the array
Next line contains N spaced integers, the elements in the array.
Output a single integer which contains the maximum non-carry sum thus obtained
2 ≤ N ≤ 10^5
1 ≤ elements of array < 10^9
Time limit: 2s
Input: 5 34 56 83 19 38 Output: 92
|Time Limit:||1 - 2 sec|
|Source Limit:||50000 Bytes|
Fetching successful submissions