I tried alot to think about an idea to solve this problem but I couldn't find the way to solve it so I need help.
I have searched the internet alot but didnt find a good article about min cost max flow
given a directed graph each edge has cost for transfering one unit and capacity that spicify maximum number of units can pass the edge find minmum total cost to transfer K units from node S to node T(not neccessery max flow only K units)
can you give me good article to solve this problem
I need help to solve this problem
given a tree with N nodes and K robots you want minimize the total distance needed to visit each node at least once by one robot if all robots started at node i.
robots are allowed to stop at any node and don't move.
for each node i from 1 to N output the answer if all robots started from node i, more details is in the link above.
I got problem and can't solve it:
given an array consist of N integers A1,A2,A3...An
for each element i from 1 to n you should increase all elements j by (1) such that j<i and A[j]>=A[i]
example: the array is:
4 2 1 3
nothing before 1 so thing will happen here
A[i]=2 so we need to increase all element before i and bigger or equal than A[i] by 1
so the array become:
5 2 1 3
increase all element before i and bigger ort equal than A[i] by 1
the array become:
6 3 1 3
finally when i=4 :
the array become:
7 4 1 3
so print the new array to the output
sorry for my English.
thanks in advance.
Given an array with N elements you have to execute two different types of querys:
1- add to the array an element with value X (anywhere).
2- answer how many elements which have value bigger than l and smaller than r.
number of querys<=100,000
I think it can be done using self-balancing binary search tree (for example AVL tree),
but is there is a way easier than this data structure?
I need an ONLINE solution
Given an Array with N elements each element have 3 integers Say Ai,Bi,Ci.
you have to answer Q querys given in each query 3 integers X,Y,Z you have to say how many elements in the array satisfy Ai>=X , Bi>=Y Ci<=Z
I hope you help me or give me a hint, thanks.
I need help to solve this problem http://www.spoj.pl/problems/OILCOMP/
in this problem we 2D array A[H][W] and we need to select elements of the array without selecting any two neighbor elements and maximize the sum of the elements selected.
the neighbors of element A[ i ][ j ] is A[ i-1 ][ j ] , A[ i+1 ][ j ] , A[ i ][ j-1 ] , A[ i ][ j+1 ].
I heard that this problem can be solved two ways, the first is network flow and the second is dp with bitmasks
I need to know both ways please.
I need help with this problem ,because I have no idea how to solve this
You have an array with N elements (1<=N<=1000), you need to sort this array in non-increasing order, you can only move the element in position i to position j: 1- by swaping i and i+1 then swaping i+1 and i+2 ... swaping j-1 and j (if i<j) 2- by swaping i and i-1 then swaping i-1 and i-2 ... swaping j+1 and j (if i>j) in both operations the cost of the operation is i+j find the minimal cost that you can sort the array non-increasing order input: first line contains integer N second line contains N space-separated integers the elements of the array output: one integer the minimal cost Sample test: input: 5 20 30 5 15 10 output: 11 Note: in the sample test moving element in position 3 to 5 will cost (3+5)=8 moving the element in position 2 to 1 will cost (2+1)=3 total cost 3+8=11
Hi, If i want to compute (1065*1001) mod 1000 , the best way to do this is computing (1065 modulo 1000) and (1001 modulo 1000) then Multiplying the two numbers so (1065 modulo 1000) = 65 and (1001 modulo 1000) = 1 then 65 * 1 = 65 so: (1065*1001) mod 1000 = 65 this way is much easier than computing 1065*1001 then modulo 1000
so my question is: is there a way resemble to the way above working with division like (6072/1012) mod 5 thanks.