119 - Greedy Gift Givers

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

Moderator: Board moderators

Post Reply
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

Dont create new thread when there already exist about that topic and
Dont Cry
:lol: there is search option
search for 119
Iffat
New poster
Posts: 25
Joined: Sat Jul 22, 2006 9:47 am

PE !!!!!!!!!!!!!!!!!!!!!

Post by Iffat »

i am getting PE...:x :x :x i don't know where is my mistake...even i read all the posts...
here is my code

Code: Select all

REMOVED
plz plz plz plz plz plz help me :cry: :cry: :cry: :cry: :cry: :cry:
Last edited by Iffat on Tue Dec 05, 2006 8:32 am, edited 1 time in total.
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind »

Iffat, dont print blank line after last case.
Iffat
New poster
Posts: 25
Joined: Sat Jul 22, 2006 9:47 am

Post by Iffat »

thanks for reply...i changed the part of my code..but still P.E :(

Code: Select all

printf("\n\n");
for(i=1;i<=n;i++)
	{
		if(i!=1)
		 printf("\n");	
		printf("%s %ld",str[i],arr1[i]);
		
		strcpy(str[i],"\0");
	}

printf("\n");

thanx
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

I think you have changed the wrong part. See the code below...

Code: Select all

caseno=0;
while(input())
{
	/* Process */
	if(caseno++)
		printf("\n");
	for(i=1;i<=n;i++)
		printf("%s %ld\n",str[i],arr1[i]);
	/* Rest of the Code, But no printing */
}
Hope it helps.
Ami ekhono shopno dekhi...
HomePage
linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

Not getting AC!

Post by linux »

What's wrong with my code? Can anyone help?

Code: Select all

#include<stdio.h>
#include<string.h>

main()
{
       int np,i,j,k,amount,ppbal[12],nopp,ebal;
       char ppname[10][12],whoname[12];

       while (scanf("%d",&np)!=EOF) {
               for (i=0;i<np;i++) {
                       scanf("%s",ppname[i]);
                       ppbal[i]=0;
               }
 /*Deleted after AC*/
               for (i=0;i<np;i++) {
                       printf("%s %d\n",ppname[i],ppbal[i]);
               }
               putchar('\n');

       }
       return 0;

}
The problem was in char string which should be declared greater for the NULL pointer. Got AC. :P
Last edited by linux on Thu Sep 11, 2008 9:44 pm, edited 2 times in total.
Solving for fun..
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton »

hmm!
GoldExcalibur
New poster
Posts: 3
Joined: Wed Mar 07, 2007 2:16 pm

Post by GoldExcalibur »

my code got WA for times....I have tested it using some input case I found in this forum....n it produced right answer... Can anybody give me advice to correct my code? thanks a lot

Code: Select all


 /** DELETED AFTER AC **/

Last edited by GoldExcalibur on Tue Mar 27, 2007 6:08 pm, edited 3 times in total.
GoldExcalibur
New poster
Posts: 3
Joined: Wed Mar 07, 2007 2:16 pm

Post by GoldExcalibur »

Isn't there anybody who can help me to find out where the mistake is?
I really can't find it....please give me any test case(s) which can help me figure out the mistake..really appreciate any help n response..thanks a lot.
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio »

Change

Code: Select all

while(!feof(stdin)){

  scanf("%d",&member);
to

Code: Select all

while (scanf("%d", &member) != EOF) {
I don't know why feof() doesn't work. I think its already discussed somewhere.

And don't print newline after the last case.
After AC, don't forget removing your code.
GoldExcalibur
New poster
Posts: 3
Joined: Wed Mar 07, 2007 2:16 pm

Post by GoldExcalibur »

what a mistake....

Thanks rio.....mine is already AC, really appreciate your help. thanks
owokko
New poster
Posts: 7
Joined: Sat Apr 28, 2007 7:11 am

Post by owokko »

I get a problem with 119. Can anyone help me, please

I have test the groups of size 0 and 1. and test the case i found in this board but still get wrong :cry: .

If the group with 0 person, my code will output "\n", if the group with equal or more than 1 person, it can work.

please test my code and find the bug.

my code

and th main test case
Input: http://fdemesmay.dyndns.org/cs/acm/v1/119.in
Output: http://fdemesmay.dyndns.org/cs/acm/v1/119.out

Code: Select all

//Question http://acm.uva.es/p/v1/119.html
//CPU: , Memory: 

#include <iostream>
#include <cstring>

using namespace std;

char name[10][13];

  
int main()
{   
while(true){
    if( cin.fail() )
        break; 
        
    int n, own[10];//={0};
    
    cin >> n;


     /* remove */
}
Last edited by owokko on Sat May 05, 2007 6:33 am, edited 1 time in total.
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

Replace the following part

Code: Select all

...
int main()
{
while(true){
    if( cin.fail() )
        break;

    int n, own[10];//={0};

    cin >> n;
...
with

Code: Select all

...
int main()
{
    int n;

    while(cin >> n){

        int own[10];//={0};
...
Hope it helps.
Ami ekhono shopno dekhi...
HomePage
owokko
New poster
Posts: 7
Joined: Sat Apr 28, 2007 7:11 am

Post by owokko »

Thanks for kindness reply. :D

I change the part in my code and solve the problem. :)
MateuszM
New poster
Posts: 1
Joined: Wed Jun 27, 2007 7:44 pm
Location: Poland

input sample

Post by MateuszM »

I also had problem with WA in 119.
In my case it was wrong output when nr of presents was 0

try follwing input:

2
dave liz
dave 200 0
liz 100 1 dave


you should get output:
dave 100
liz -100
Post Reply

Return to “Volume 1 (100-199)”