0% found this document useful (0 votes)
16 views

Problem - D - Codeforces

The document describes a programming problem from Codeforces Round 1009 (Div. 3) titled 'Counting Points'. It requires participants to calculate the number of integer points that lie inside or on the border of given circles based on their centers and radii, with specific constraints on input size and test cases. The output should be the count of such points for each test case provided.

Uploaded by

dhruvs2209
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Problem - D - Codeforces

The document describes a programming problem from Codeforces Round 1009 (Div. 3) titled 'Counting Points'. It requires participants to calculate the number of integer points that lie inside or on the border of given circles based on their centers and radii, with specific constraints on input size and test cases. The output should be the count of such points for each test case provided.

Uploaded by

dhruvs2209
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

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 m1.codeforces.com
m1.codeforces.com,, m2.codeforces.com
m2.codeforces.com,, m3.codeforces.com
m3.codeforces.com.. ×

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

https://codeforces.com/contest/2074/problem/D 1/1

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy