|
|
back to boardsort(a + 1, a + 1 + n); reverse(a + 1, a + 1 + n); for(int i = 1; i <= n; i++){ if(sum1 > sum2){ sum2 += a[i]; } else{ sum1 += a[i]; } } cout << abs(sum1 - sum2); let me give you an example 13 14 27 if I understand your solution you are sorting it and then add to left or to the right. in this example the diff is 0 what your program returns? The same thing. I tried to enter almost everything, it works correctly, but i always have WA on 5 test Test Case : 5 5 5 4 3 3 2 Test Case : 5 5 5 4 3 3 Edited by author 15.01.2019 16:49 Edited by author 06.11.2018 20:49 |
|
|