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 ??
11054 - Wine trading in Gergovia
Moderator: Board moderators
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
-
- Experienced poster
- Posts: 136
- Joined: Fri Apr 15, 2005 3:47 pm
- Location: Singapore
- Contact:
-
- A great helper
- Posts: 481
- Joined: Sun Jun 19, 2005 1:18 am
- Location: European Union (Slovak Republic)
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...

-
- Experienced poster
- Posts: 136
- Joined: Fri Apr 15, 2005 3:47 pm
- Location: Singapore
- Contact:
-
- Guru
- Posts: 724
- Joined: Wed Dec 19, 2001 2:00 am
- Location: Germany
Re: 11054 - Wine trading in Gergovia
Hey My code Works for all inputs in sample and here's ... But I am getting WA . Why ?? here is the code ..
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;
}
I know I am a Failure Guy . 

Re: 11054 - Wine trading in Gergovia
Use fabs for double variable cost. 

A person who sees the good in things has good thoughts. And he who has good thoughts receives pleasure from life... Bediuzzaman