Given two sorted postive integer arrays A[n] and B[n] (W.L.O.G, let's
say they are decreasingly sorted), we define a set S = {(a,b) | a \in A
and b \in B}. Obviously there are n^2 elements in S. The value of such
a pair is defined as Val(a,b) = a + b. Now we want to get the n pairs
from S with
Start merging A and B from the tail end for N elements, just like the way
you would do it for a merge sort but with a different constraint based on
the sum a[i] and b[i]
This should work for any value of N, I just hard-coded it for simplicity.
#includestdio.h
#define N 6
struct OutputType {
Hi,
Take an example :
Array A: {a1,a2,a3,a4,a5}- (sorted decreasingly)
Array B :{b1,b2,b3,b4,b5}- (sorted decreasingly)
First pair is(a1,b1) .
Now for Second pair Compare the sum of (b1,a2) and (a1,b2) whichever is
greater .
if (a1,b2) is the second pair then now compare (b1,a2) and (a1,b3)
This question was already discussed.
On 14 October 2010 15:36, Manish K manish.ag...@gmail.com wrote:
Hi,
Take an example :
Array A: {a1,a2,a3,a4,a5}- (sorted decreasingly)
Array B :{b1,b2,b3,b4,b5}- (sorted decreasingly)
First pair is(a1,b1) .
Now for Second pair Compare the sum of
@AlgoSau Sau
*
*
Stack and Qeueue are different. In case of stack insertions and deletions
happen at only one end. That has favoured in devising a DS which returns min
value in O(1) complexity. In Queue we insert at one end and delete at other
end. The technique applied to stack can not be
@Mridul Malpani
Can you please justify your proposition.
On Fri, Oct 8, 2010 at 11:22 PM, Mridul Malpani malpanimri...@gmail.comwrote:
i think we can use poisson distribution formulae for it.
On Oct 7, 2:02 pm, malli mallesh...@gmail.com wrote:
An interesting puzzle. Assume size of each
I am trying to solve this problem, got some idea but am not
clear...please give your input...
http://www.codechef.com/problems/MONEY
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
I am trying to solve this problem, got some idea but am not
clear...please give your input...
http://www.codechef.com/problems/MONEY
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to
by forming n*n pairs of points. now you have to select any 2 pair such
that these 2 set have atleast 1 points in common, and their slope must
be equal.
this will take O(n^4).
correct me, if i m wrong.
On Oct 14, 7:00 am, Dave dave_and_da...@juno.com wrote:
@Asquare. Yes, you are wrong. If the
@ Mridul -
even I had the same confusion.. Wht dave says is not this..
He is considering one point at a time (say A) and checking the
maximum
number of points (say n) which have the same slope with A...
now wen he considers the next point (say B) and calculates slope with
B
for all other points
@ Shiv -
ur method will fail for
22
/ \
47 7
/
35
/\
17 45
\
90
here 17 35 45 90 shd be the tree
but in ur case as the first right is encountered (i.e. 45) the array
would reset and not consider 90.
--
You received this message because you are
https://www.spoj.pl/problems/MAXSUMSQ/
hi i m getting wrong ans for this problem .. can anybody tell me where
i m going wrong..thx in advance..
#includeiostream
#includecstdio
using namespace std;
main()
{
int t;
//cint;
scanf(%d,t);
while(t--)
{
long long
How will one go about extracting a random number from a bitset ?
let's say i have a bitset
1001101000100010001
where 1 denote what numbers are currently present in the set
How can one extract these ones in a random manner .Generating a random
number modulo size of the bitset won't work as
There's no great way to do it that I can see.
You can generate random numbers mod the bitset size until one happens
to fall on the index of a 1. Of course if 1's are sparse, this can
take a while.
You can count the number N of 1's and generate a random number I mod
N. Then scan the bitset
I wrote the book Economic Analysis of Information Systems (written in
Portuguese).
See my blog: http://sergiokaminski.blogspot.com/
The basic economic principles of computer science, written in
Portuguese, Spanish and English.
--
You received this message because you are subscribed to the Google
15 matches
Mail list logo