CNEASY - CN Tower (Easy)

no tags 

Christy C. Coder is traveling to Waterloo for a programming competition. On the way, she stops in Toronto to do some sightseeing. The unfortunate thing about travelling is that everyone back home expects her to bring back pictures of everything. Christy hates taking pictures: it makes her look like such a tourist! Fortunately, Christy has a plan to make her picture-taking quite painless.

At 553 m tall, CN Tower is the world's tallest free-standing building. 351 m up the tower is the "360" rotating restaurant, which rotates a full 360 degrees every 72 minutes. From there, Christy can see the whole city, and take close-up pictures of all the landmarks using her fancy new 100x optical zoom camera. Since the restaurant itself rotates, she only needs to stand in one place to take pictures in all directions.

The waiters insist that she order something or leave, and Christy is not interested in any of the items on the menu. Therefore, she must act quickly before she gets kicked out. Given the locations of the landmarks of which Christy wants to take a picture, your task is to determine the minimum amount of time that she must spend in the restaurant in order for it to rotate enough to bring all the landmarks in view. Assume that Christy always points her camera exactly perpendicular to the window to minimize distortion due to the glass. Note that multiple landmarks may occupy the same (angular) position, and these landmarks would only require one photograph to capture them.

Since the restaurant staff only realize she is a tourist once she starts taking pictures, we begin measuring the time required once she takes her first picture. Therefore, Christy can move to any position in the restaurant without hassle from the restaurant staff and begin taking pictures from there.


The first line of input consists of the number of test cases. For each test case, the first line is an integer n (2 ≤ n ≤ 1000), the number of landmarks Christy wants to photograph. Each of the following n lines specify a landmark. Each landmark specification consists of the landmark name (a string of uppercase and lowercase letters of length at most 40 characters), a space, and the compass angle d, in degrees, to the landmark from the CN Tower (0 = north, 90 = east, 180 = south, 270 = west). Note that d is a real number which satisfies 0 ≤ d < 360, with d specified to the hundredth of a degree (i.e., at most two decimal places).


For each test case, output a single integer, the minimum number of seconds that Christy must remain in the restaurant. If the time is not an integer number of seconds, round it up to the nearest second (i.e., take the ceiling of the number).


CasaLoma 231.0
OntarioParliament 123.0
SkyDome 75.0
RoyalYorkHotel 340.0
PearsonAirport 165.0


hide comments
akulsareen: 2013-12-21 19:09:22

Vectors aren't that slow. Used vectors and got a 0.01. That's also probably because I used cin and cout.

Satyam Vijay: 2013-07-18 16:41:19

When using vectors, the solution gave tle. But when I changed it to a float array, it got accepted with time 0.00. I never considered vectors to be this slow.

Satyam Vijay: 2013-07-18 16:40:43

When using vectors, the solution gave tle. But when I changed it to a float array, it got accepted with time 0.00. I never considered vectors to be this slow.

mystique_blue: 2013-03-16 16:31:43

Just keep your bheja cool and solve. No prob with double. Dont try to do anything special. :)

SHUBHAM KANSAL: 2013-01-21 13:34:00

precision error cost me 3 WA .

Last edit: 2013-01-21 13:34:18
Ashok: 2012-11-08 13:59:55

100th problem :)

Andy: 2012-09-09 07:36:41

use floor(ans+0.99) for double

strings: 2012-09-09 07:36:41

can some one please give some other test cases... i have used %f in c, and even integer calculations and my machine is giving right ans fr test cases i made...
still WA??? :(

Ikhaduri: 2012-09-09 07:36:41

I still have WA.... any more test cases?

saket diwakar: 2012-09-09 07:36:41

got AC.:)
use %f in C...

Added by:Bobby Xiao
Time limit:1s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Resource:Canadian Computing Competition, 2006 Senior Stage 2