Bored Maru
InterviewTime limit1sMemory limit1024 MB
Each order covers a circular arc of 2b degrees centered opposite the wall point at angle a. Count the integer sensors hit by at least one arc.
- Level
Easy3 of 10
- Topics
- Intervals, Prefix sum, Implementation
- Solved
- No attempts yet
Problem
Geunsu is a disciple of the grand wizard Maru. Recently Maru taught Geunsu Blaze, a skill that lets the user face a chosen direction and spread fire through a chosen angle.
Bored Maru wants to test Geunsu's Blaze. Blaze sends fire out endlessly in a specific direction and angle, so Maru tests it inside a special circular training ground. The ground is enclosed by a wall, so when Blaze is used inside, the fire hits the wall and disappears. The wall has sensors that detect Blaze, and they are very sensitive. They detect Blaze even at the boundary where it passes.
Maru orders Geunsu to use Blaze times. Each order is as follows.
Maru: Starting from the entrance, move counterclockwise along the wall of the training ground by , then cast Blaze toward the center of the training ground across a range of .
The figure below shows Maru's order.

In the figure, points are the center of the training ground, the entrance, and Geunsu's position. \newcommand{arc}\[1]{\stackrel{\Large\frown}{#1}}\arc{LR} is the range of Blaze that hit the wall and disappeared. The solid lines in the figure are the wall. Geunsu always uses Blaze so that hold.
Geunsu, the top disciple, can always use Blaze exactly. Print the number of sensors that detected Blaze after Geunsu follows all orders. There is one sensor at the entrance and 360 sensors in total, one every .
When , the sensor at Geunsu's position does not detect Blaze. When , it does.
Input
The first line contains the integer , the number of orders Maru gives Geunsu. ()
From the second line to line , each line contains the integers and of the -th order, separated by a space. (; )
Output
Print one line containing the number of sensors that detected Blaze after Geunsu follows all orders.