10465 - Homer Simpson

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

Moderator: Board moderators

prom
New poster
Posts: 10
Joined: Thu Jul 25, 2002 11:58 pm
Location: Poland

10465 - Homer Simpson

Post by prom »

[cpp]
#include <iostream.h>
#include <string.h>


#define min(a,b)(a<b ? a : b)
#define MAX 10005

int tt[MAX];

int main(){
int m,n,t;
while (cin >> m >> n >> t){
memset(tt,0,4*(t+1));
tt[m]=(m!=0);
tt[n]=(n!=0);
int i=min(m,n);
while (i<=t)
{
if (tt){
if (i+m<=t && tt+1>tt[i+m] ) tt[i+m]=tt+1;
if (i+n<=t && tt+1>tt[i+n] ) tt[i+n]=tt+1;
}
++i;
}
if (tt[t]==0){
int i=t-1;
int imin=0;
while (i>-1){
if ( tt>tt[t] ) { tt[t]=tt; imin=i; }
--i;
}

cout<<tt[t]<<" "<<t-imin;
cout<<endl;
}
else cout << tt[t]<<endl;

}
return 0;
}
[/cpp]

Does anyone have some tests ?. I couldn't what's wrong with my code.[/cpp]
prom
New poster
Posts: 10
Joined: Thu Jul 25, 2002 11:58 pm
Location: Poland

Post by prom »

I know what's wrong. If Simpson has to drink some beer, then th time of drinking shuld be minimized :)
KE4MTG
New poster
Posts: 15
Joined: Sat Jul 06, 2002 3:31 am
Location: Florida, USA

DID IT WORK?

Post by KE4MTG »

Hey prom, did you get the program working. just curious to see if the minimal drinking is true. Cause they sure didn't say so.
turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:

Post by turuthok »

Hello, KE4MTG ... prom is right.

Check this clarification about Homer Simpson problem:

http://acm.uva.es/board/viewtopic.php?t=2429

Good luck,

-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).
Rajputro
New poster
Posts: 6
Joined: Fri Jan 10, 2003 4:19 pm
Location: Dhaka,Bangladesh
Contact:

Still Confused :(

Post by Rajputro »

My sample inputs
4 4 10
1 7 10
2 3 6
11 2 13
2 5 25
3 4 5

My programme's output...

2 2
10
3
2
11
1 1

Am I correct?? If so still I gor a W.A :( otherwise what's wrong with
this samples??
Larry
Guru
Posts: 647
Joined: Wed Jun 26, 2002 10:12 pm
Location: Hong Kong and New York City
Contact:

Post by Larry »

I got:

Code: Select all

2 2
10
3
2
11
1 1
Have you tried m, n >t ?
Sajid
Learning poster
Posts: 94
Joined: Sat Oct 05, 2002 5:34 pm
Location: CS - AIUB, Dhaka, Bangladesh.
Contact:

Post by Sajid »

To Larry,

i have got WA as well.. the above output is OK in my program, too..

what about the following input???

Code: Select all

20 30 7
100 8 1
the Output in my program....

Code: Select all

0 7
0 1
is it correct???
Sajid Online: www.sajidonline.com
turuthok
Experienced poster
Posts: 193
Joined: Thu Sep 19, 2002 6:39 am
Location: Indonesia
Contact:

Post by turuthok »

Sajid, ... my AC-ed program returns the same output as yours.

-turuthok-
The fear of the LORD is the beginning of knowledge (Proverbs 1:7).
Sajid
Learning poster
Posts: 94
Joined: Sat Oct 05, 2002 5:34 pm
Location: CS - AIUB, Dhaka, Bangladesh.
Contact:

Post by Sajid »

Turuthuk, then what is the problem.. i cant get... :(

can u tell me more critical inputs???, plz
Last edited by Sajid on Fri Mar 07, 2003 3:30 am, edited 1 time in total.
Sajid Online: www.sajidonline.com
raysa
New poster
Posts: 40
Joined: Wed Dec 18, 2002 4:23 pm
Location: Indonesia

Post by raysa »

Maybe you can try this:
Input:

Code: Select all

5 3 5
4 5 7
9 7 62
2 5 6
45 23 91
5 9 19
4 6 42
3 7 10
12 56 71
50 51 103
My solution gives:
Output:

Code: Select all

1
1 2
8
3
3
3
10
2
2 3
2 1
G' Luck ^_^!
Raysa
Rajputro
New poster
Posts: 6
Joined: Fri Jan 10, 2003 4:19 pm
Location: Dhaka,Bangladesh
Contact:

Furious and frustated

Post by Rajputro »

Give me a simple input for which my programme..Gives answer different from u...

In fact all the samples from this page satisfy my programme very well..

:(
-->Shafi

" Rajputro has spoken. "
KE4MTG
New poster
Posts: 15
Joined: Sat Jul 06, 2002 3:31 am
Location: Florida, USA

Post by KE4MTG »

Hey guys, Raysa for your second to last data set - 12 56 71, I get 5 11 instead of 2 3. I don't see how 2 3 is possible. Thanks everyone for the input. I get all the same answers as you guys. Also thanks turuthok. I fixed my program though I haven't submitted yet. Going to now.
KE4MTG
New poster
Posts: 15
Joined: Sat Jul 06, 2002 3:31 am
Location: Florida, USA

Post by KE4MTG »

o wait hahah never mind =) sorry
KE4MTG
New poster
Posts: 15
Joined: Sat Jul 06, 2002 3:31 am
Location: Florida, USA

Post by KE4MTG »

i'm just stupid, forget what i said raysa
Rajputro
New poster
Posts: 6
Joined: Fri Jan 10, 2003 4:19 pm
Location: Dhaka,Bangladesh
Contact:

At last

Post by Rajputro »

Understood the problem and Got accepted :D:D:D:D:D:D:D

123 12 21 was the faulty input which helped me to correct my problem
-->Shafi

" Rajputro has spoken. "
Post Reply

Return to “Volume 104 (10400-10499)”