119 - Greedy Gift Givers
Moderator: Board moderators
-
- A great helper
- Posts: 383
- Joined: Mon Oct 18, 2004 8:25 am
- Location: Bangladesh
- Contact:
PE !!!!!!!!!!!!!!!!!!!!!
i am getting PE... i don't know where is my mistake...even i read all the posts...
here is my code
plz plz plz plz plz plz help me
here is my code
Code: Select all
REMOVED
Last edited by Iffat on Tue Dec 05, 2006 8:32 am, edited 1 time in total.
-
- A great helper
- Posts: 383
- Joined: Mon Oct 18, 2004 8:25 am
- Location: Bangladesh
- Contact:
thanks for reply...i changed the part of my code..but still P.E
thanx
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
I think you have changed the wrong part. See the code below...
Hope it helps.
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 */
}
Ami ekhono shopno dekhi...
HomePage
HomePage
Not getting AC!
What's wrong with my code? Can anyone help?
The problem was in char string which should be declared greater for the NULL pointer. Got AC.
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;
}
Last edited by linux on Thu Sep 11, 2008 9:44 pm, edited 2 times in total.
Solving for fun..
-
- New poster
- Posts: 3
- Joined: Wed Mar 07, 2007 2:16 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.
-
- New poster
- Posts: 3
- Joined: Wed Mar 07, 2007 2:16 pm
Change
to
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.
Code: Select all
while(!feof(stdin)){
scanf("%d",&member);
Code: Select all
while (scanf("%d", &member) != EOF) {
And don't print newline after the last case.
After AC, don't forget removing your code.
-
- New poster
- Posts: 3
- Joined: Wed Mar 07, 2007 2:16 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 .
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
I have test the groups of size 0 and 1. and test the case i found in this board but still get wrong .
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.
Replace the following part
with
Hope it helps.
Code: Select all
...
int main()
{
while(true){
if( cin.fail() )
break;
int n, own[10];//={0};
cin >> n;
...
Code: Select all
...
int main()
{
int n;
while(cin >> n){
int own[10];//={0};
...
Ami ekhono shopno dekhi...
HomePage
HomePage
input sample
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
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