Page 10 of 10

### Re: 119 Why WA??

Posted: Fri Jun 13, 2014 9:28 am
Whatever compiler the default is in XCode 5.1.

### Re: 119 Why WA??

Posted: Fri Jun 27, 2014 12:09 pm
gtcoder wrote:
Input

Code: Select all

``````2
Fat Dude
Fat 1000 0
Dude 100 1 Fat
``````
Output

Code: Select all

``````Fat 100
Dude -100
``````
3. Print a blank line after each case except the last one.
when money given to 0 it becomes 0?
what happens 0 given to anyone?

Code: Select all

``laura 0 2 amr vick``

### Re: 119 Why WA??

Posted: Fri Jun 27, 2014 8:31 pm
Blief.S wrote:when money given to 0 it becomes 0?
I'm afraid I don't understand this question, but see if the comments below help.
Blief.S wrote:what happens 0 given to anyone?
If 0 money is given (as with laura in the sample), that 0 is divided by the number of people to give gifts to, and that result is added to the "net worth" of those people. Just as with any other amount. If you carefully analyze the first sample from the problem statement, you can clearly see what is the result of laura giving away 0 to two friends.

I think the problem statement is failry clear, so when in doubt, take the time to patiently read it as many times as necessary until you understand all the details.

### Re: 119 Why WA??

Posted: Sat Jun 28, 2014 2:47 pm

### Re: 119 Why WA??

Posted: Sat Jun 28, 2014 2:52 pm
Thanks lbv...

### 119 - Keep getting WA even though i test many many times

Posted: Fri Nov 21, 2014 9:24 am

Code: Select all

``````#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <vector>
using namespace std;
typedef vector<string> vs;

int indexP(vs& a, string s)
{
for(int i =0; i < a.size(); i++)
{
if(a[i] == s)
return i;
}
return -1;
}

int main()
{
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
freopen("input.txt", "r", stdin);
int n;
//cout << "enter amount person" << endl;
while(cin >> n)
{
cin.ignore();
vs name;
int money[n], cash, amt;
//cout << "enter: " << endl;
for(int i = 0; i < n; i++)
{
cin >> temp;
name.push_back(temp);
money[i] = 0;
}
for(int i = 0; i < n; i++)
{
cin >> owner;
int index = indexP(name, owner);
cin >> cash;
cin >> amt;
cin.ignore();
if(amt != 0){
leftover = cash%amt;
//cout << money[index] << endl;
money[index] = (money[index] - cash + leftover);
while(amt--)
{
}
}
}
for(int i = 0; i < n; i++)
{
cout << name[i] << " " << money[i] << endl;
}
cout << "\n";
}
return 0;
}
``````

### Re: 119 - Keep getting WA even though i test many many times

Posted: Fri Nov 21, 2014 12:14 pm
Post in existing thread. Use search by problem number (119). Don't read from file or post here code that you actually submit. Problem description says
The output for each group should be separated from other groups by a blank line
Don't print blank line after last case

### Re: 119 - Keep getting WA even though i test many many times

Posted: Fri Nov 21, 2014 12:26 pm
I'm sorry for posting into a new thread. But you solved my problem. Thanks a alot.

Posted: Thu May 07, 2015 12:55 pm
Hi I am getting wrong answer from the following code and not able to trace error.Could you help me ?

Code: Select all

``````import java.util.Scanner;
import java.util.HashMap;

class Main{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
while (true) {
int n = 0;
try {
n = sc.nextInt();
} catch (Exception e) {
break;
}
String[] friends =new String[n];
HashMap<String,Integer> map=new HashMap<String,Integer>();
for(int i=0;i<n;i++)
{
friends[i]=sc.next();
map.put(friends[i], i);
}
int []money=new int[n];
for(int i=0;i<n;i++)
{
int idx = map.get(sc.next());
int M = sc.nextInt();
if (M!= 0) {
for(int j=0;j<M;j++)
{
money[map.get(sc.next())]+=dev;
}
}
}
for(int j=0;j<n;j++)
{
System.out.println(friends[j] + " " + money[j]);
}
}
}
}``````

Posted: Sun Jun 07, 2015 7:57 pm
The output for each group should be separated from other groups by a blank line.

### Re: 119 - Greedy Gift Givers

Posted: Mon Sep 14, 2015 10:06 pm
Please tell me why this code is getting WA?

Code: Select all

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

int main ()
{
long np, i, money, person, divide, c, flag = 0;

while (scanf ("%ld", &np) != EOF) {

struct friends {
int spend;
char name [20];
} A [12] = {0, 0, 0};

for (i = 0; i < np; i++)
scanf ("%s", A [i].name);

for (c = 0; c < np; c++ ) {

scanf ("%s", giver);
scanf ("%ld", &money);

i = 0;
while (strcmp (A [i].name, giver) != 0)
i++;
A [i].spend += money;

scanf ("%ld", &person);
if (person == 0) {
continue;
}

divide = person;
A [i].receive += money - ((money / person) * person);
while (person--) {
i = 0;
while (strcmp (A [i].name, receiver) != 0)
i++;
A [i].receive += (money / divide);
}
}

if (flag == 1)
printf("\n");
flag = 1;

for (i = 0; i < np; i++)
printf("%s %ld\n", A [i].name, A [i].receive - A [i].spend);
}
return 0;
}``````
EDIT: Problem solved. Thank You