|
|
back to boardShow all messages Hide all messagesI got accepted but the algoritm is wrong. It fails on 6 6 6 5 4 3 2 my answer = 2 the real answer = 0 (6+5+2 6+4+3) #include <stdio.h> int main(){ int n; int sum(0), half(0); int stones[100000]; scanf("%d",&n); for(int c=0; c<n;c++){ scanf("%d",&stones[c]); sum+=stones[c]; } half=sum/2; for(int c=0; c<n; c++) if(half>=stones[c])half-=stones[c]; printf("%d\n",(half*2+sum%2)); } Up Scalar 20 Mar 2009 13:48 i can be wrong, but i think your test consists three "6" while in your "real answer" there are only two of them) You are wrong. Author wrote test in one line. First number is a count of stone. Right test 6 6 6 5 4 3 2, right answer 0, author answer 2. up Scalar 24 Mar 2009 14:04 up Scalar 27 Mar 2009 01:43 up Scalar 31 Mar 2009 23:05 up Scalar 8 Apr 2009 17:38 Admins! Is really bug on this problem! Pleace add this test. it fails also on 5 5 8 13 27 14 .... the real answer is 3 but yours is 15!! strange but admin did not add test for this wrong solution. i sent it(solution) to system and system accepted it! |
|
|