|
|
вернуться в форумWhy my program WA ????why why ?? #include <stdio.h> #include <algorithm> using namespace std ; int main(int argc, char* argv[]) { int N ; long i ; double inta[100001]; long sum1 , sum2 ; while(scanf("%d",&N)!=EOF) { for( i = 0 ;i < N ; i ++) scanf("%lf",&inta[i] ) ; sort(inta , inta + N); sum1 = inta[N-1] ; sum2 = inta[N-2] ; for( i = N-3 ; i>=0 ;i--) { if( sum1 >= sum2 ) { sum2 += inta[i] ; } else sum1 += inta[i] ; } printf("%ld\n",abs(sum1-sum2) ); } return 0; } //--------------------------------------------------------------------------- Re: Why my program WA ????why why ?? Послано Lomir 22 сен 2007 10:56 Cause your solution is wrong. 5 3 3 2 2 2 answer 0 |
|
|