ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1005. Stone Pile

Why WA 5 test?
Posted by Meyrlan 14 Jul 2018 04:35
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?
Posted by popraducj 14 Sep 2018 23:53
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?
Posted by Ayoba 15 Sep 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?
Posted by Milon Hossain 6 Nov 2018 20:49
Test Case :
5
5 5 4 3 3
Re: Why WA 5 test?
Posted by Milon Hossain 6 Nov 2018 20:49


Edited by author 06.11.2018 20:49
Re: Why WA 5 test?
Posted by Konstantin 14 Jan 2019 17:15
2
Test Case :
5
5 5 4 3 3


Edited by author 15.01.2019 16:49
Re: Why WA 5 test?
Posted by Mapu 22 Jan 2019 08:57
4
15 16 30 2

Answer 1