144 - Student Grants

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

Dominik Michniewski
Guru
Posts: 834
Joined: Wed May 29, 2002 4:11 pm
Location: Wroclaw, Poland
Contact:

Post by Dominik Michniewski »

My accepted solution outputs:

Code: Select all

  5  4  3  1  2
  8 10 12 14 16 18 20 21 22 23  5  7 17 24  1  3  4  6 13 15 19 25  2 11  9
  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
  1
  1
  4  6  8  9 10  1  2  3  7  5
 10  8  9  7  5  4  6  2  3  1
  2  3  1
  2  4  6  8 10 12 14 16 18 20 22  3  7 11 15 19  1  5  9 13 17 21
 10 11 12 13  9  6  7  8  5  2  4  1  3
Best regards
DM
If you really want to get Accepted, try to think about possible, and after that - about impossible ... and you'll get, what you want ....
Born from ashes - restarting counter of problems (800+ solved problems)

Guest
New poster
Posts: 39
Joined: Wed May 19, 2004 5:52 pm
Location: Dhaka, Bangladesh
Contact:

Thanks!

Post by Guest »

Thanks Dominik,
I've corrected my mistake and got AC. :D

outsbook
New poster
Posts: 26
Joined: Fri Oct 28, 2011 2:42 am

144 - Student Grants

Post by outsbook »

Read this line carefully
" When the machine is switched on in the morning, with an empty output store, it immediately moves 1 coin into the output store. When that has been dispensed it will then move 2 coins, then 3, and so on until it reaches some preset limit k. It then recycles back to 1, then 2 and so on."

1. When output store empty then the machine move coin. At part move 1 coin, then 2 coins, then 3 coins, and so on. If moving coin exit the limit k then the machine move 1 coin, then 2 coins, and so on. (Remember that the machine move coin when output store is empty).
2. A student withdraw coin role: If x coins in output store, a student need y coin
a. If x==y then the student withdraw y coins and leave the student. Now output store is empty.
b. if x>y then the student withdraw y coins and leave the student. Now (x-y) coin in output store.
c. if x<y then the student withdraw y coins and the student rejoins the queue at the end.

Just simulate the process using a queue of objects that hold a student number and an amount of money remaining.
"Learning to love yourself is the greatest love of all" - Michael Masser and Linda Creed

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 144 Student Grants

Post by uDebug »

Dominik Michniewski wrote:My accepted solution outputs:
Thanks for sharing this. It helped me debug my code.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 144 - Student Grants

Post by uDebug »

Folks,

Be sure to also check out this thread.

http://acm.uva.es/board/viewtopic.php?f ... 8c9bdaeef5

There are some great test cases there.
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 144 - Students' Grants (WA)

Post by uDebug »

ec3_limz wrote:Are there hidden traps in this problem? Please help.
Good job! You're nearly there, actually.

All you need is to print a newline after each test case. So, something like this after Line #44 should do the trick.

Code: Select all

printf("\n");
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.

Zyaad Jaunnoo
Experienced poster
Posts: 122
Joined: Tue Apr 16, 2002 10:07 am

Re: 144 - Student Grants

Post by Zyaad Jaunnoo »

Pay attention to the following points:
1) ...The amount remaining in the store is then available for the next student.
Here, the machine does not dispense additional coins. The next student takes whatever is left in the store.

2) In your output, all numbers must be right justified in a field of width 3. This is important to avoid a Presentation Error.

Post Reply

Return to “Volume 1 (100-199)”