11/03/2025, 21:25 Problem - D - Codeforces
|
DhruvS2209 | Logout
HOME TOP CATALOG CONTESTS GYM PROBLEMSET GROUPS RATING EDU API CALENDAR HELP RAYAN
Reminder: in case of any technical issues, you can use the lightweight website [Link]
[Link],, [Link]
[Link],, [Link]
[Link].. ×
PROBLEMS SUBMIT CODE MY SUBMISSIONS STATUS STANDINGS CUSTOM INVOCATION
Codeforces Round 1009 (Div. 3)
D. Counting Points Contest is running
time limit per test: 2 seconds
01:09:55
memory limit per test: 256 megabytes
Contestant
The pink soldiers drew n circles with their center on the x -axis of the plane. Also, they have told that the sum of radii is exactly m∗ .
Please find the number of integer points inside or on the border of at least one circle. Formally, the problem is defined as follows.
n
You are given an integer sequence x 1 , x 2 , … , x n and a positive integer sequence r 1 , r 2 , … , r n , where it is known that ∑i=1 r i = m . → Submit?
You must count the number of integer pairs (x, y) that satisfy the following condition.
Language: GNU G++23 14.2 (64 bit, msy
There exists an index i such that (x − x i ) 2 + y
2
≤ r
2
i
(1 ≤ i ≤ n ). Choose
Choose file No file chosen
file:
∗
Is this information really useful? Don't ask me; I don't really know.
Submit
Input
Each test contains multiple test cases. The first line contains the number of test cases t (1
4
≤ t ≤ 10 ). The description of the test cases
follows.
The first line of each test case contains two integers n and m (1
5
≤ n ≤ m ≤ 2 ⋅ 10 ).
9 9
The second line of each test case contains x 1 , x 2 , … , x n — the centers of the circles (−10 ≤ x i ≤ 10 ).
n
The third line of each test case contains r 1 , r 2 , … , r n — the radii of the circles (1 ≤ ri , ∑i=1 r i = m ).
It is guaranteed that the sum of m over all test cases does not exceed 2 ⋅ 10 . 5
Output
For each test case, output the number of integer points satisfying the condition on a separate line.
Example
input Copy
4
2 3
0 0
1 2
2 3
0 2
1 2
3 3
0 2 5
1 1 1
4 8
0 5 10 15
2 2 2 2
output Copy
13
16
14
52
Note
On the first test case, the circle with r 1 = 1 is completely inside the circle with r 2 = 2 . Therefore, you only have to count the number of
2
integer points inside the latter. There are 13 integer points such that x 2 + y
2
≤ 2 , so the answer is 13 .
On the second test case, the circle with r 1 = 1 is not completely inside the circle with r 2 = 2 . There are 3 additional points that are inside
the first circle but not inside the second circle, so the answer is 3 + 13 = 16.
Codeforces (c) Copyright 2010-2025 Mike Mirzayanov
The only programming contests Web 2.0 platform
Server time: Mar/11/2025 20:18:01UTC+5.5 (i2).
Desktop version, switch to mobile version.
Privacy Policy
Supported by
[Link] 1/1