cegprakash's blog

By cegprakash, 8 years ago, In English

Problem 1:

1) You need to buy exactly n pies where n is no. of days

2) You must have bought at least i pies after ith day

3) If you buy x pies on a day, you'll have to spend sum of cost of pies + x*x

Within a day, you can greedily pick the smallest pies.

Putting them into a DP of two states where DP[i][j] means optimal cost of buying j pies starting from day i will give an AC.

Complexity : O(days * days * days)

Problem 2:

We can move the points inside a random circle of any radius into the resultant square. (but each point gets translated by dx,dy)

The final answer is the number of points inside a square of given side length which we need to maximize.

One of the optimal ways is that the circle is chosen such that it is bigger than the resultant square.

Suppose if we have two squares of same side length, we can move all the points from one square to another square. We can always draw a circle outside one of these squares and move to other square and it'll not affect the result.

Two loops from 0 to n-1 to find a square from any two points.

Another two loops from 0 to n-1 to find a square from any two points.

Final loop to count the number of points inside these two squares.

This is an O(n^5) solution and is not optimal one. Feel free to comment optimal methods if any.

Problem 3

We need the shortest distance between any two nodes before we can proceed. This can be found using Floyd Warshall in O(n^3).

Lets assume we are currently at node currNode and the truck is loaded with L items and already delivered to D families.

This 3 variables currNode, L, D forms a state

DP[currNode][L][D] denotes the optimal way from currentNode when the truck is already loaded with L family items and D families are yet to be served.

When L = 0, we cannot deliver anything. i.e. we must load from next family.

When L = 2, we cannot load anything. i.e. we must deliver the first loaded family.

When L = 1, we can either deliver or load.

Overall complexity : O(n^3 + n * families)

Full text and comments »

  • Vote: I like it
  • -32
  • Vote: I do not like it

By cegprakash, 12 years ago, In English

The battle of the Coders kicks off with hordes of programming geeks, ready to pit their coding and logical thinking skills to the test against the best on the battlefield of SPOJ. Compete against some of the most astute programming minds across the world to experience nail-biting tension and the ecstatic joy of coding, at the Online Programming Contest of Kurukshetra. Do you look both ways before crossing a one — way street? Then you are the programmer we are looking for!

For details visit : http://kurukshetra.org.in/#!/events/onlineprogramming

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By cegprakash, 12 years ago, In English

We would like to invite you all to participate in Kurukshetra OPC 2013, a 5-hour acm-icpc style online programming competition, which is organized as a part of Kurukshetra 2013, the international technical fest of College Of Engineering Guindy, Anna University, India.

Date: 24th Jan 2013
Start time: 20:00 IST
Contest Duration : 5 hours
Contest link: www.spoj.com/KOPC13

Prizes worth: 40,000 INR

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it

By cegprakash, 13 years ago, In English
I'm using Windows 7 and topcoder arena applet is blocked in our college wifi.

In Topcoder proxy settings it asks for Proxy type, Host and Port details.. could anyone help me in that plz..

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By cegprakash, 14 years ago, In English
We would like to invite you all to participate in ITRIX OPC 11(An Individual Contest ), a 2-hour acm-icpc style online programming competition, which is organized as a part of ITRIX 2011 , the Technical fest of DIST ,College Of Engineering Guindy,India.          
                                      
Start time : Sunday ,27th March 2011,8 pm IST .[ Find when it starts in your time zone Time in Other Zones]


Problem Setters: innocentboy2,sundargates
Contact: radhakrishnancegit@gmail.com
Problems : 5 - 6 problems with mix of easy (2), medium (2) and hard (1-2) levels.


Prize Money in INR 

First Place: 10000 INR
II place : 3000 INR
III place : 2000 INR

Practice contest is running: https://www.spoj.pl/ITRIXTST/
For more details visit: https://www.itrix.org.in

Full text and comments »

  • Vote: I like it
  • +3
  • Vote: I do not like it