http://www.codechef.com/viewsolution/5200401 this is the link to the solution which i am trying to submit but i am not understanding why i am getting W.A???
Your approach is right,you should try changing your 32bit datatypes to 64bit datatypes (use long long int or int64_t instead of int and long int).
Brother, try these:-
Test1:
Input:
5
2 -5 -2 -1 6
Output:
16
=============================================
Test 2:
Input:
12
-51 -22 56 -9 47 -59 99 -61 0 -191 999 -808
Output:
1286
============================================
Test3:
Input:
9
-15 3 -7 24 -19 17 -5 3 -1
Output:
71
=========================================
Test4:
Input:
19
51 -999 474 -14 -21 -764 41 -42 -64 -99 -444 -616 1111 -63 1201 6666
Output:
17464
====================================================
Test5:
Input:
6
-91555 -45617 75642 -66454 12345 115639
Output:
533880
===================================================
Test6:
Input:
7
9494 1427 -6479 4976 -12465 6654 -3607
Output:
40929
1 Like