Page 2 of 2

Posted: Sun Jul 23, 2006 6:45 pm
by Martin Macko
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.

Posted: Sun Jul 23, 2006 6:45 pm
by jan_holmes
the range of long long in C/C++ is the same as long in Java... but long in C/C++ might be the same as integer in Java... so it depends on which language you choose.... :D

Posted: Sun Jul 23, 2006 6:48 pm
by Martin Macko
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...
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... :wink:

Posted: Sun Jul 23, 2006 6:48 pm
by jan_holmes
Thx ferng1021 for your explanation about the sample input... AC now... :wink:

Posted: Sun Jul 23, 2006 6:50 pm
by JetBrain
oh.. Thanks a lot Martin.. the reason was the 'long long' thing ;)..
its AC now.. :)

Posted: Sun Jul 23, 2006 6:54 pm
by JetBrain
what made me use 'long' not 'long long' is that when I use it, I get an error & the program doesnt work (I am using Visual Studio 6.0) .. does it need special header or sth??

anyway, its AC after all :)

Posted: Sun Jul 23, 2006 6:58 pm
by JetBrain
me too... AC now..
the problem was that I was using 'long' not 'long long'

Thanks a lot for ur help..

Posted: Sun Jul 23, 2006 6:59 pm
by Adrian Kuegel
long long is not standard, therefore not every compiler supports it.
However, in this problem you could have used double as well (since the biggest result is 2.5 * 10^12, or in general n^2/4 * 1000).

Posted: Sun Jul 23, 2006 7:07 pm
by JetBrain
Thanks Adrian

Re: 11054 - Wine trading in Gergovia

Posted: Fri Dec 19, 2014 6:34 pm
by ssavi
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;
}

Re: 11054 - Wine trading in Gergovia

Posted: Sun Dec 21, 2014 10:35 am
by lighted
Use fabs for double variable cost. :)