Posted: Sun Jul 23, 2006 6:45 pm
In C/C++ compiler used here int and long stand for 32 bit (signed) integer types and long long for a 64 bit (signed) integer type.JetBrain wrote:what is long long ?? is that different from long ??
In C/C++ compiler used here int and long stand for 32 bit (signed) integer types and long long for a 64 bit (signed) integer type.JetBrain wrote:what is long long ?? is that different from long ??
If you generate and post here some test cases, I can compute the corect outputs for you. Or if nothing helps, you can still post your code here...JetBrain wrote:Hi Martin
I tried ur sample input.. I am getting the same output as urs..
I dont know why am I getting WA !!!
my solution is O(n)..
Thanks anyway...
Code: Select all
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
int main()
{
long long int a[100000], t, i, j, s;
double cost;
while(scanf("%lld",&t)==1)
{
if(t==0)
break;
for(i=1;i<=t;i++)
scanf("%lld",&a[i]);
cost= s=a[1];
for(i=2;i<=t;i++)
{
s = (s+a[i]);
cost=abs(cost)+abs(s);
}
printf("%0.0lf\n",cost);
}
return 0;
}