Page 2 of 3

Posted: Tue Oct 24, 2006 9:56 pm
by fpavetic
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

Posted: Tue Oct 24, 2006 10:14 pm
by Artikali
thanks accepted
using

cin>> - 8.705
getchar - 8.055

Posted: Tue Oct 24, 2006 10:36 pm
by little joey
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.

Posted: Wed Oct 25, 2006 6:27 am
by Darko
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.

Posted: Thu Oct 26, 2006 3:57 pm
by navid_a2b
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

Posted: Thu Oct 26, 2006 4:18 pm
by Darko
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.

Posted: Thu Oct 26, 2006 4:28 pm
by navid_a2b
thank you Darko , "%lld" was the matter , i got AC only changing this.

Posted: Sat Oct 28, 2006 11:08 am
by farzane
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;
	}
}



Posted: Sat Oct 28, 2006 11:52 am
by rio
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

Posted: Tue Oct 31, 2006 11:12 pm
by sclo
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.

Re: 11136 - Hoax or what

Posted: Wed Jan 12, 2011 7:50 pm
by zobayer
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.

Re: 11136 - Hoax or what

Posted: Mon Mar 28, 2011 6:51 pm
by Rashad
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. :)

Re: 11136 - Hoax or what

Posted: Mon Aug 20, 2012 9:34 am
by tzupengwang
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

Re: 11136 - Hoax or what

Posted: Mon Aug 20, 2012 9:29 pm
by aerofoil.kite
tzupengwang wrote:

Code: Select all

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

Re: 11136 - Hoax or what

Posted: Tue Aug 21, 2012 3:34 pm
by tzupengwang
I'm still a new user of "set"
Thank you very much ~
I get AC now!!