11136 - Hoax or what
Moderator: Board moderators
-
- Guru
- Posts: 1080
- Joined: Thu Dec 19, 2002 7:37 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
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.
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.
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.
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;
}
}
try this
the answer should be
Code: Select all
2
2 1 1
2 2 5
3
6 1 2 3 4 5 6
0
0
0
Code: Select all
3
9
-
- Experienced poster
- Posts: 110
- Joined: Tue May 06, 2008 2:18 pm
- Location: CSE-DU, Bangladesh
- Contact:
Re: 11136 - Hoax or what
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.
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.
Re: 11136 - Hoax or what
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. 



-
- New poster
- Posts: 36
- Joined: Fri Dec 02, 2011 1:30 pm
- Location: Kaohsiung, Taiwan
Re: 11136 - Hoax or what
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!!
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.
-
- New poster
- Posts: 12
- Joined: Tue Dec 06, 2011 8:59 pm
- Location: Bangladesh
- Contact:
Re: 11136 - Hoax or what
You should clear your multiset m after each test case...tzupengwang wrote:Code: Select all
multiset<long long int> m;
-
- New poster
- Posts: 36
- Joined: Fri Dec 02, 2011 1:30 pm
- Location: Kaohsiung, Taiwan
Re: 11136 - Hoax or what
I'm still a new user of "set"
Thank you very much ~
I get AC now!!
Thank you very much ~
I get AC now!!