Codeforces Round 858 (Div. 2)

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
1806 Codeforces Round 858 (Div. 2) FINISHED False 8100 58125262 March 18, 2023, 12:05 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 364 ) F1 GCD Master (easy version) PROGRAMMING greedy math number theory sortings

B'This is the easy version of the problem. The only difference between the two versions is the constraint on m . You can make hacks only if both versions of the problem are solved. You are given an array a of length n and two integers m and k . Each element in a satisfies 1 <= a_i <= m . In one operation, you choose two indices i and j such that 1 <= i < j <= |a| , then append gcd(a_i,a_j) to the back of the array and delete a_i and a_j from the array. Note that the length of the array decreases by one after this operation. Find the maximum possible sum of the array after performing exactly k operations. The first line contains a single integer t ( 1 <= t <= 10^5 ) -- the number of test cases. The description of test cases follows. The first line of each test case contains three integers n , m and k ( 2 <= n <= 10^6 ; 1 <= m <= 10^6 ; 1 <= k <= n-1 ). The second line of each test case contains n integers a_1,a_2, ldots,a_n ( 1 <= a_i <= m ). It is guaranteed that the sum of n over all test cases does not exceed 10^6 and the sum of m over all test cases does not exceed 10^6 . For each test case, output the maximum possible sum of the array after performing k operations optimally. In the first test case, the best way is to choose i=1 , j=3 in the first operation. The final sequence is [7,4] . '...

Tutorials

Codeforces Round #858 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
198041678 Star32 F1 March 19, 2023, 4:47 a.m. OK GNU C++14 TESTS 59 327 48128000
197981473 Walid_Ebaid F1 March 18, 2023, 3:16 p.m. OK GNU C++14 TESTS 59 530 31232000
197980157 2021_yes F1 March 18, 2023, 3:08 p.m. OK GNU C++17 TESTS 59 467 23347200
198016127 FatihSolak F1 March 18, 2023, 8 p.m. OK GNU C++17 (64) TESTS 59 202 48128000
198033998 Cxny F1 March 19, 2023, 2:17 a.m. OK GNU C++17 (64) TESTS 59 701 72192000
197976042 taa1 F1 March 18, 2023, 2:49 p.m. OK GNU C++17 (64) TESTS 59 702 16076800
198034225 wind_cross F1 March 19, 2023, 2:23 a.m. OK GNU C++20 (64) TESTS 59 78 12083200
198033840 triveni F1 March 19, 2023, 2:13 a.m. OK GNU C++20 (64) TESTS 59 156 16076800
198034081 triveni F1 March 19, 2023, 2:19 a.m. OK GNU C++20 (64) TESTS 59 171 16076800
197990085 DeadlyPillow F1 March 18, 2023, 4:15 p.m. OK GNU C++20 (64) TESTS 59 171 22937600
197978649 steelxack F1 March 18, 2023, 3 p.m. OK GNU C++20 (64) TESTS 59 186 80179200
198039123 njwrz F1 March 19, 2023, 4:04 a.m. OK GNU C++20 (64) TESTS 59 187 16076800
198039397 mazihang2022 F1 March 19, 2023, 4:09 a.m. OK GNU C++20 (64) TESTS 59 187 80179200
198011577 maypdejewpo F1 March 18, 2023, 7:13 p.m. OK GNU C++20 (64) TESTS 59 187 80179200
198029251 5af F1 March 19, 2023, 12:10 a.m. OK GNU C++20 (64) TESTS 59 202 80179200
197977639 AlperenT F1 March 18, 2023, 2:55 p.m. OK GNU C++20 (64) TESTS 59 217 56320000

remove filters

Back to search problems