Codeforces Round 653 (Div. 3)

Solutions are presented as using the least memory and the fastest execution time. It also takes the top 10 most recent solutions from each language. If you want to limit to a specific index, click the "Solved" button and go to that problem.

ContestId
Name
Phase
Frozen
Duration (Seconds)
Relative Time
Start Time
1374 Codeforces Round 653 (Div. 3) FINISHED False 7200 143997911 June 28, 2020, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 24639 ) D Zero Remainder Array PROGRAMMING math sortings two pointers

B"You are given an array a consisting of n positive integers. Initially, you have an integer x = 0 . During one move, you can do one of the following two operations: The first operation can be applied no more than once to each i from 1 to n . Your task is to find the minimum number of moves required to obtain such an array that each its element is divisible by k (the value k is given). You have to answer t independent test cases. The first line of the input contains one integer t ( 1 <= t <= 2 cdot 10^4 ) -- the number of test cases. Then t test cases follow. The first line of the test case contains two integers n and k ( 1 <= n <= 2 cdot 10^5; 1 <= k <= 10^9 ) -- the length of a and the required divisior. The second line of the test case contains n integers a_1, a_2, ... , a_n ( 1 <= a_i <= 10^9 ), where a_i is the i -th element of a . It is guaranteed that the sum of n does not exceed 2 cdot 10^5 ( sum n <= 2 cdot 10^5 ). For each test case, print the answer -- the minimum number of moves required to obtain such an array that each its element is divisible by k . Consider the first test case of the example: Note that you can't add x to the same element more than once. "...

Tutorials

79517

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
85386118 Gassa D June 28, 2020, 4:41 p.m. OK D TESTS 19 124 28979200
85385076 Gassa D June 28, 2020, 4:37 p.m. OK D TESTS 19 139 28979200
85376091 Gassa D June 28, 2020, 4:21 p.m. OK D TESTS 19 140 10854400

remove filters

Back to search problems