|
|
вернуться в форумWhy WA 5 test? sort(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); Re: Why WA 5 test? 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? Re: Why WA 5 test? Послано Ayoba 15 сен 2018 00:38 The same thing. I tried to enter almost everything, it works correctly, but i always have WA on 5 test Re: Why WA 5 test? Test Case : 5 5 5 4 3 3 Re: Why WA 5 test? Edited by author 06.11.2018 20:49 Re: Why WA 5 test? 2 Test Case : 5 5 5 4 3 3 Edited by author 15.01.2019 16:49 Re: Why WA 5 test? Послано Mapu 22 янв 2019 08:57 4 15 16 30 2 Answer 1 |
|
|