← Back to topics
Topic

Task Jagode

D
Dgleich
Solved..
*EDIT CODE REMOVED!
f
fushar
Can you please explain the task in English? I don't understand Serbian....
p
picsel
You are given a number N - number of squares (farms).
In the next N lines, there are 3 real numbers. First number is X coordinate of the lower left corner of the square, and second number is Y coordinate. 3rd number is the length of the square's side.

You have to find 2 lines parallel to Y-axis that divide the squares in 3 parts, so that the total area of all the squares (or parts of the squares) in all 3 parts is equal (all the farmers have to get equal area of the farm). Then you have to write the X coordinate of those 2 lines.
So if the total area of all the farms is, for example, 300, each farmer has to get 100.

In the sample test, first farmer gets 2/3 of the first farm, second farmer gets 1/3 of the first farm and 1/3 of the second farm, and third farmer gets 2/3 of the second farm.
m
msantl
Your mistake is here

for ( int i = 0 ; i < n ;i++) {
pocy = point [ i ].y; <------------
dulj = point [ i ].a;



you sholudn't take the y coordinate

I thnik that first 5 TC are that x=y
f
fushar
Sorry, can the rectangles overlap?
m
msantl
No, they can't overlap
D
Dgleich
Oh thanks what a silly mistake , it fails on Last one now :D
D
Dgleich
Solved ,thanks everyone...
M
MilosRadic
any hints for this task:D
A
Al3kSaNdaR
Binary search for both X coordinates .
M
MilosRadic
but how can i know which farms should be divided
A
Al3kSaNdaR
Hmm ,

Go binary search for some X1 that when you draw normal line to X-axis in X1 on your left side you have 1 / 3 of total Area, then Binary search for X2 that when you draw normal line to X-axis in X2 on your rights side you have 1/3 of total Area .