题目描述
Problem Description
Commentary: "Amazing! Saito-san, who appeared like a comet in the figure skating world, has captivated us! How did you find this performance?"
Analysis: "Well, there were no noticeable mistakes, and the technical execution was high, so we can expect quite a high score."
Commentary: "Despite being such a skilled skater, Saito-san is also known for his top-notch fan service. During his post-skate greeting, he performs the following actions:"
- Starts skating from a single gate, completes exactly one clockwise lap around a 5000m skating rink, and exits the gate to head for the kiss & cry.
- Skates at a constant speed of 1 m/s without deviation.
- Picks up all the stuffed toys that are lying on the ice.
- Catches any stuffed toys that are thrown exactly at him while he is skating.
Commentary: "Additionally, the audience is well-trained and throws stuffed toys in a refined manner:"
- Exactly 10 seconds after the specified time listed, the stuffed toys land precisely at the designated spot.
Analysis: "These stuffed toys are small enough to be negligible in size, so multiple toys can land in the same spot. Also, Saito-san can pick up as many toys as he wants without slowing down. Isn't that amazing?"
Commentary: "That's incredible. Let's see how many stuffed toys Saito-san can pick up!"
Input Format
The input is given from the standard input in the following format:
$ N $ $ t_{1} $ $ d_{1} $ $ m_{1} $ $ t_{2} $ $ d_{2} $ $ m_{2} $ $ : $ $ t_{N} $ $ d_{N} $ $ m_{N} $
- $ N $: The number of people throwing stuffed toys
- $ t $: The elapsed time (in seconds) since Saito-san started skating, with the start time being 0 seconds
- $ d $: The distance (in meters) clockwise from the starting point on the skating rink
- $ m $: The number of stuffed toys thrown
- $1 \leq N \leq 10000$, $0 \leq t \leq 4990$, $1 \leq d \leq 5000$, $1 \leq m \leq 10$ ($ N, t, d, m $ are integers)
Output Format
Output the total number of stuffed toys that can be picked up.
Sample Input and Output
Sample Input #1
3
100 200 1
200 300 2
300 400 3
Sample Output #1
6
Sample Input #2
3
100 50 1
200 100 2
300 200 3
Sample Output #2
0
Sample Input #3
1
0 10 1
Sample Output #3
1
Notes/Hints
Sample Explanation 1
Ten seconds after 100 seconds, the first spectator's stuffed toy lands 200 meters ahead of the starting point, which is collectable. The subsequent toys from the other two spectators are also collectable.
Sample Explanation 2
Ten seconds after 100 seconds, the first spectator's stuffed toy lands 50 meters ahead of the starting point, which is not collectable. The subsequent toys from the other two spectators are also not collectable.
Sample Explanation 3
Ten seconds after 0 seconds, the first spectator's stuffed toy lands 10 meters ahead of the starting point, which is collectable.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分