Problem - D - Codeforces
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 m1.codeforces.com
m1.codeforces.com,, m2.codeforces.com
m2.codeforces.com,, m3.codeforces.com
m3.codeforces.com.. ×
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
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.
Supported by
https://codeforces.com/contest/2074/problem/D 1/1