11054 - Wine trading in Gergovia

All about problems in Volume 110. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Post by Martin Macko » Sun Jul 23, 2006 6:45 pm

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.

jan_holmes
Experienced poster
Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore
Contact:

Post by jan_holmes » Sun Jul 23, 2006 6:45 pm

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

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Post by Martin Macko » Sun Jul 23, 2006 6:48 pm

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:

jan_holmes
Experienced poster
Posts: 136
Joined: Fri Apr 15, 2005 3:47 pm
Location: Singapore
Contact:

Post by jan_holmes » Sun Jul 23, 2006 6:48 pm

Thx ferng1021 for your explanation about the sample input... AC now... :wink:

JetBrain
New poster
Posts: 15
Joined: Sun Jul 23, 2006 4:24 pm
Location: Cairo, Egypt
Contact:

Post by JetBrain » Sun Jul 23, 2006 6:50 pm

oh.. Thanks a lot Martin.. the reason was the 'long long' thing ;)..
its AC now.. :)

JetBrain
New poster
Posts: 15
Joined: Sun Jul 23, 2006 4:24 pm
Location: Cairo, Egypt
Contact:

Post by JetBrain » Sun Jul 23, 2006 6:54 pm

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 :)

JetBrain
New poster
Posts: 15
Joined: Sun Jul 23, 2006 4:24 pm
Location: Cairo, Egypt
Contact:

Post by JetBrain » Sun Jul 23, 2006 6:58 pm

me too... AC now..
the problem was that I was using 'long' not 'long long'

Thanks a lot for ur help..

Adrian Kuegel
Guru
Posts: 724
Joined: Wed Dec 19, 2001 2:00 am
Location: Germany

Post by Adrian Kuegel » Sun Jul 23, 2006 6:59 pm

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).

JetBrain
New poster
Posts: 15
Joined: Sun Jul 23, 2006 4:24 pm
Location: Cairo, Egypt
Contact:

Post by JetBrain » Sun Jul 23, 2006 7:07 pm

Thanks Adrian

ssavi
New poster
Posts: 28
Joined: Thu Nov 20, 2014 9:57 pm

Re: 11054 - Wine trading in Gergovia

Post by ssavi » Fri Dec 19, 2014 6:34 pm

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 . :(

lighted
Guru
Posts: 585
Joined: Wed Jun 11, 2014 9:56 pm
Location: Kyrgyzstan, Bishkek

Re: 11054 - Wine trading in Gergovia

Post by lighted » Sun Dec 21, 2014 10:35 am

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

Post Reply

Return to “Volume 110 (11000-11099)”