11136 - Hoax or what

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

Moderator: Board moderators

fpavetic
Learning poster
Posts: 51
Joined: Sat Mar 04, 2006 8:00 pm

Post by fpavetic » Tue Oct 24, 2006 9:56 pm

artikali: just add ml.clear() at the begining of each case and you'll get your solution accepted

although i am surprised that a solution using cin for reading passes

Artikali
Learning poster
Posts: 68
Joined: Wed Sep 21, 2005 5:27 pm

Post by Artikali » Tue Oct 24, 2006 10:14 pm

thanks accepted
using

cin>> - 8.705
getchar - 8.055

User avatar
little joey
Guru
Posts: 1080
Joined: Thu Dec 19, 2002 7:37 pm

Post by little joey » Tue Oct 24, 2006 10:36 pm

That's because just reading all input and no processing using cin takes 1.5 seconds; using getch() it takes 0.8 seconds.
Don't forget to remove your code.

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko » Wed Oct 25, 2006 6:27 am

Interesting... I read everything in using System.in.read(byte[],int,int) in... 0.180 secs! Of course, if memory is tight I can't keep everything around, but I think I should stop whining... or something.

navid_a2b
New poster
Posts: 10
Joined: Mon Oct 02, 2006 4:32 pm
Location: Tehran,Iran
Contact:

Post by navid_a2b » Thu Oct 26, 2006 3:57 pm

hello , can anyone tell me what's wrong with my code ? or give me a case
which my code fails to respond correctly ?thanks in advance

Code: Select all

removed
Last edited by navid_a2b on Thu Oct 26, 2006 4:26 pm, edited 1 time in total.

Darko
Guru
Posts: 580
Joined: Fri Nov 11, 2005 9:34 am
Location: Calgary, Canada

Post by Darko » Thu Oct 26, 2006 4:18 pm

Oh, man... I like your solution... a lot :)

I think if you just print the result properly (%lld), it should work (I don't see a reason why it shouldn't).

[EDIT] Well, it might time out with a case that puts 1,50000,50001,100000 in and then just keeps adding 1 and 100000 every day. But that would be nasty. I still like it, though.

navid_a2b
New poster
Posts: 10
Joined: Mon Oct 02, 2006 4:32 pm
Location: Tehran,Iran
Contact:

Post by navid_a2b » Thu Oct 26, 2006 4:28 pm

thank you Darko , "%lld" was the matter , i got AC only changing this.

farzane
New poster
Posts: 26
Joined: Thu Jun 15, 2006 9:26 am

Post by farzane » Sat Oct 28, 2006 11:08 am

could somebody please tell me where is my mistake or give me I/O that my program fails.I'm getting Wa.

Code: Select all

#include<iostream.h>
#include<fstream.h>

void main(){
//	ifstream cin("a.in");
	long long dayno,sum,max1,max2,min1,min2,bill,I,K,n;
	cin>>dayno;
	while(dayno>0){
		sum=0;
		max1=max2=0;
		min1=min2=1000001;
		for(I=0;I<dayno;I++){
			cin>>n;
			for(K=0;K<n;K++){
				cin>>bill;
				if(bill>max1){
					max2=max1;
					max1=bill;
				}else if(bill>max2)
					max2=bill;
				if(bill<min1){
					min2=min1;
					min1=bill;
				}else if(bill<min2)
					min2=bill;
			}
			sum+=max1-min1;
			max1=max2;
			max2=0;
			min1=min2;
			min2=0;
		}
		cout<<sum<<endl;

		cin>>dayno;
	}
}



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

Post by rio » Sat Oct 28, 2006 11:52 am

try this

Code: Select all

2
2 1 1
2 2 5
3
6 1 2 3 4 5 6
0
0
0
the answer should be

Code: Select all

3
9

sclo
Guru
Posts: 519
Joined: Mon Jan 23, 2006 10:45 pm
Location: Vancouver, BC, Canada
Contact:

Post by sclo » Tue Oct 31, 2006 11:12 pm

StanleY Yelnats wrote:I used two priority queue however it was a WA
but the algorithm seems to be ok, i'm still working on it

( WA in 2.2sec )
I used 2 priority queue and it works, you need to check for duplicates.

zobayer
Experienced poster
Posts: 110
Joined: Tue May 06, 2008 2:18 pm
Location: CSE-DU, Bangladesh
Contact:

Re: 11136 - Hoax or what

Post by zobayer » Wed Jan 12, 2011 7:50 pm

I got AC (Rank 1 by now, 0.156s) with STL set (not multiset) and a buffer of 16MB with fread(). 12MB also works.
Note: the erase operation in set can be done in constant time for this problem, and it's not always necessary to erase or insert in the set. With scanf, same algorithm takes around 0.340s.
You should not always say what you know, but you should always know what you say.

Rashad
New poster
Posts: 17
Joined: Tue Dec 22, 2009 4:20 pm

Re: 11136 - Hoax or what

Post by Rashad » Mon Mar 28, 2011 6:51 pm

I am getting WA in this problem. :( I don't know whats wrong with my algo. :-? Please give me some I/O. Thaks in advance. :)

tzupengwang
New poster
Posts: 36
Joined: Fri Dec 02, 2011 1:30 pm
Location: Kaohsiung, Taiwan

Re: 11136 - Hoax or what

Post by tzupengwang » Mon Aug 20, 2012 9:34 am

I am getting WA with this problem
I use "multiset" to store all the bills
and I am wondering where the mistake is?
Can anyone help? Thanks!!

Code: Select all

/*11136*/
Removed after AC
Last edited by tzupengwang on Tue Aug 21, 2012 3:34 pm, edited 1 time in total.

User avatar
aerofoil.kite
New poster
Posts: 12
Joined: Tue Dec 06, 2011 8:59 pm
Location: Bangladesh
Contact:

Re: 11136 - Hoax or what

Post by aerofoil.kite » Mon Aug 20, 2012 9:29 pm

tzupengwang wrote:

Code: Select all

multiset<long long int> m;
You should clear your multiset m after each test case...

tzupengwang
New poster
Posts: 36
Joined: Fri Dec 02, 2011 1:30 pm
Location: Kaohsiung, Taiwan

Re: 11136 - Hoax or what

Post by tzupengwang » Tue Aug 21, 2012 3:34 pm

I'm still a new user of "set"
Thank you very much ~
I get AC now!!

Post Reply

Return to “Volume 111 (11100-11199)”