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
User avatar
emotional blind
A great helper
Posts: 383
Joined: Mon Oct 18, 2004 8:25 am
Location: Bangladesh
Contact:

Post by emotional blind » Wed Sep 20, 2006 6:07 pm

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 » Mon Dec 04, 2006 8:35 pm

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.

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

Post by emotional blind » Mon Dec 04, 2006 10:59 pm

Iffat, dont print blank line after last case.

Iffat
New poster
Posts: 25
Joined: Sat Jul 22, 2006 9:47 am

Post by Iffat » Tue Dec 05, 2006 8:29 am

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 » Tue Dec 05, 2006 3:52 pm

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

User avatar
linux
Learning poster
Posts: 56
Joined: Sat Jul 01, 2006 12:21 pm
Location: CA-95054
Contact:

Not getting AC!

Post by linux » Mon Feb 12, 2007 8:49 am

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

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Post by newton » Sat Feb 17, 2007 2:19 pm

hmm!

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

Post by GoldExcalibur » Wed Mar 07, 2007 2:30 pm

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 » Tue Mar 27, 2007 3:13 pm

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.

User avatar
rio
A great helper
Posts: 385
Joined: Thu Sep 21, 2006 5:01 pm
Location: Kyoto, Japan

Post by rio » Tue Mar 27, 2007 3:45 pm

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 » Tue Mar 27, 2007 6:02 pm

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 » Fri May 04, 2007 4:21 pm

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 » Fri May 04, 2007 8:09 pm

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 » Sat May 05, 2007 9:51 am

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 » Wed Jun 27, 2007 7:53 pm

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