OK here is my code
#includestdio.h
#includealgorithm
#includeutility
using namespace std;
int compareints (const void * a, const void * b)
{
return ( *(long*)a - *(long*)b );
}
int main()
{
int n,s[101],a,b,c,d,e,f;
long p1[19],p2[19];
int i,j,k;
scanf(%d,n);
and here is my code I'm Getting TLE i tried to implement binary search
but failed bcoz how will i be able to trace the value from one vector into
another vector if there are any multiple occureneces of any value(i mean i
have count them).in this code i i have used count of algorithm which
upper_bound and lower_bound does a binary search to get count of alike
terms.. which u tend to sum of to get the ans..
out of the two arrays, u need to sort one array.. this will be teh vector in
which u do the binary search wit every element of un sorted array..
this is the approach i used... :)
I did used the library functions but I am getting sigsegv after 0.03 s.I
cant understand why?I am presuming sumthing wrong about the implemenatation
of bsearch?
I am assuming bsearch is returning a pointer to the first found element.
On Sun, Jun 12, 2011 at 12:41 PM, keyan karthi
hint: u ve commented some vital part of ur code ;)
On Sun, Jun 12, 2011 at 12:46 PM, saurabh singh saurab...@gmail.com wrote:
I did used the library functions but I am getting sigsegv after 0.03 s.I
cant understand why?I am presuming sumthing wrong about the implemenatation
of bsearch?
I am
@keyan..your advice was really very helpful...the time limit has come under
control ...1.4s but now i am getting WA though my code is giving right ans
for the test cases...can you plz help me in figuring out where it fails ..
On Sun, Jun 12, 2011 at 12:59 AM, keyan karthi
forgot to attach the code...here is the modified code..
#includevector
#includeiostream
#includealgorithm
#includecstdio
#includecmath
using namespace std;
int main()
{
int num,ans=0,value,i,j,k,t,a,b,c,d,e,f;
scanf(%d,num);
vectorint val,a1,a2;
for(i=0;inum;i++)
{
I am trying really hard to get this one fixed,still cant find any
problem..:-(
On Sun, Jun 12, 2011 at 1:45 PM, nicks crazy.logic.k...@gmail.com wrote:
forgot to attach the code...here is the modified code..
#includevector
#includeiostream
#includealgorithm
#includecstdio
@saurabh,nick: u cant divide by 0.. u need to check it while generating the
array..
i used somethin like this...
1. void fun(int n)
2. {
3. int a,b,cl;
4. for(a=0;an;a++)
5. {
6. for(b=0;bn;b++)
7. {
8. for(cl=0;cln;cl++)
9. {
10.
where I am I dividing by 0?
i have used the check
if(s[l])
p1[k++]=(s[i]+s[j])*s[l];
On Sun, Jun 12, 2011 at 1:58 PM, keyan karthi keyankarthi1...@gmail.comwrote:
@saurabh,nick: u cant divide by 0.. u need to check it while generating the
array..
i used somethin like this...
1.
@keyan...that solves my problem...got AC...thanks :)
On Sun, Jun 12, 2011 at 1:15 AM, nicks crazy.logic.k...@gmail.com wrote:
forgot to attach the code...here is the modified code..
#includevector
#includeiostream
#includealgorithm
#includecstdio
#includecmath
using namespace std;
int
a,b,c,d,e,f do not need to be distinct.
(It is possible that a=b=c=d=e=f, see Example 1)
On 2011-6-10 12:01, saurabh singh wrote:
Problem link- ABCDEF https://www.spoj.pl/problems/ABCDEF/
Can someone please explain this problem.The problem says a,b,c,d,e,f
belongs to S.But what if size of S
just visit spoj forums
On Fri, Jun 10, 2011 at 9:42 AM, keyan karthi keyankarthi1...@gmail.comwrote:
the nos can repeat :) ie the valid set may contain multiple instance of a
same number..
hope this helps :)
On Fri, Jun 10, 2011 at 9:31 AM, saurabh singh saurab...@gmail.comwrote:
Problem link- ABCDEF https://www.spoj.pl/problems/ABCDEF/
Can someone please explain this problem.The problem says a,b,c,d,e,f belongs
to S.But what if size of S is smaller than 6?
I know i am missing sumthing very trivialhelp plz.
--
Saurabh Singh
B.Tech (Computer Science)
MNNIT ALLAHABAD
the nos can repeat :) ie the valid set may contain multiple instance of a
same number..
hope this helps :)
On Fri, Jun 10, 2011 at 9:31 AM, saurabh singh saurab...@gmail.com wrote:
Problem link- ABCDEF https://www.spoj.pl/problems/ABCDEF/
Can someone please explain this problem.The problem
15 matches
Mail list logo