Educational Codeforces Round 178 (Rated for 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
2104 Educational Codeforces Round 178 (Rated for Div. 2) FINISHED False 7200 30554723 April 28, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 13108 ) D Array and GCD PROGRAMMING binary search greedy math number theory

You are given an integer array (a) of size (n). You can perform the following operations any number of times (possibly, zero): pay one coin and increase any element of the array by (1) (you must have at least (1) coin to perform this operation); gain one coin and decrease any element of the array by (1). Let's say that an array is ideal if both of the following conditions hold: each element of the array is at least (2); for each pair of indices (i) and (j) ((1 \le i, j \le n); (i \ne j)) the greatest common divisor (GCD) of (a_i) and (a_j) is equal to (1). If the array has less than (2) elements, this condition is automatically satisfied. Let's say that an array is beautiful if it can be transformed into an ideal array using the aforementioned operations, provided that you initially have no coins. If the array is already ideal, then it is also beautiful. The given array is not necessarily beautiful or ideal. You can remove any elements from it (including removing the entire array or not removing anything at all). Your task is to calculate the minimum number of elements you have to remove (possibly, zero) from the array (a) to make it beautiful . The first line contains a single integer (t) ((1 \le t \le 10^4)) — the number of test cases. The first line of each test case contains a single integer (n) ((1 \le n \le 4 \cdot 10^5)). The second line contains (n) integers (a_1, a_2, \dots, a_n) ((2 \le a_i \le 10^9)). Additional constraint on the input: the sum of (n) over all test cases doesn't exceed (4 \cdot 10^5). For each test case, print a single integer — the minimum number of elements you have to remove (possibly, zero) from the array (a) to make it beautiful . In the first example, you don't need to delete any elements, because the array is already beautiful. It can be transformed into an ideal array as follows: $$$5, 5, 5 \rightarrow 4, 5, 5 \rightar

Tutorials

Educational Codeforces Round 178 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
317672483 Md_Tasrik D April 28, 2025, 8:08 p.m. OK C++17 (GCC 7-32) TESTS 7 156 14950400
317643660 ankushraj73633 D April 28, 2025, 4:14 p.m. OK C++17 (GCC 7-32) TESTS 7 171 1638400
317647412 rajpalmayur D April 28, 2025, 4:23 p.m. OK C++17 (GCC 7-32) TESTS 7 171 2048000
317642980 woralem23 D April 28, 2025, 4:12 p.m. OK C++17 (GCC 7-32) TESTS 7 171 2764800
317661616 priyanshu_sahani_10 D April 28, 2025, 6:01 p.m. OK C++17 (GCC 7-32) TESTS 7 171 3379200
317693029 wangkaibd D April 29, 2025, 4:17 a.m. OK C++17 (GCC 7-32) TESTS 7 171 3481600
317644366 pranav9354 D April 28, 2025, 4:16 p.m. OK C++17 (GCC 7-32) TESTS 7 171 3788800
317655894 gilcu3 D April 28, 2025, 5:13 p.m. OK C++17 (GCC 7-32) TESTS 7 171 4096000
317695501 pandey_animesh D April 29, 2025, 5:04 a.m. OK C++17 (GCC 7-32) TESTS 7 171 4505600
317647792 ekambareswar D April 28, 2025, 4:24 p.m. OK C++17 (GCC 7-32) TESTS 7 171 5120000
317694064 Ri_eul D April 29, 2025, 4:37 a.m. OK C++20 (GCC 13-64) TESTS 7 140 5324800
317669522 Senku D April 28, 2025, 7:27 p.m. OK C++20 (GCC 13-64) TESTS 7 140 5529600
317641907 moody07 D April 28, 2025, 4:10 p.m. OK C++20 (GCC 13-64) TESTS 7 140 7987200
317662391 Yadanesh03 D April 28, 2025, 6:09 p.m. OK C++20 (GCC 13-64) TESTS 7 140 11059200
317688965 sailTuT D April 29, 2025, 2:55 a.m. OK C++20 (GCC 13-64) TESTS 7 140 12083200
317671257 anshu.mehta D April 28, 2025, 7:48 p.m. OK C++20 (GCC 13-64) TESTS 7 155 1843200
317652183 recurze D April 28, 2025, 4:34 p.m. OK C++20 (GCC 13-64) TESTS 7 155 1945600
317674841 Kannu2k D April 28, 2025, 8:46 p.m. OK C++20 (GCC 13-64) TESTS 7 155 3481600
317660870 jusantacruzc D April 28, 2025, 5:55 p.m. OK C++20 (GCC 13-64) TESTS 7 155 5529600
317657856 SHAFIN D April 28, 2025, 5:29 p.m. OK C++20 (GCC 13-64) TESTS 7 155 5529600
317692867 Pratyushdumdumb D April 29, 2025, 4:13 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 124 1945600
317642029 star354 D April 28, 2025, 4:10 p.m. OK C++23 (GCC 14-64, msys2) TESTS 7 124 51814400
317651030 Ramzi9 D April 28, 2025, 4:32 p.m. OK C++23 (GCC 14-64, msys2) TESTS 7 140 2048000
317651698 suryanshtiwari1811 D April 28, 2025, 4:33 p.m. OK C++23 (GCC 14-64, msys2) TESTS 7 140 3481600
317666363 chrisrex D April 28, 2025, 6:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 7 140 6246400
317696953 yiwangwuqian D April 29, 2025, 5:24 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 140 7168000
317690451 stack_69 D April 29, 2025, 3:26 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 140 7168000
317656416 singhkamran084 D April 28, 2025, 5:17 p.m. OK C++23 (GCC 14-64, msys2) TESTS 7 140 9728000
317694094 dpaladiyaa D April 29, 2025, 4:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 140 10444800
317690098 raniy D April 29, 2025, 3:19 a.m. OK C++23 (GCC 14-64, msys2) TESTS 7 140 12185600
317647346 NenadDapic D April 28, 2025, 4:23 p.m. OK FPC TESTS 7 202 15462400
317643425 ruban D April 28, 2025, 4:13 p.m. OK FPC TESTS 7 874 182067200
317666694 rainboy D April 28, 2025, 6:57 p.m. OK GNU C11 TESTS 7 202 10649600
317696300 muradbhai D April 29, 2025, 5:15 a.m. OK GNU C11 TESTS 7 218 81920000
317697357 muradbhai D April 29, 2025, 5:28 a.m. OK GNU C11 TESTS 7 265 25907200
317693671 tranquyetthang281 D April 29, 2025, 4:30 a.m. OK Go TESTS 7 155 35123200
317685548 man-ray D April 29, 2025, 1:31 a.m. OK Java 21 TESTS 7 437 54681600
317644756 iamabhi1373 D April 28, 2025, 4:17 p.m. OK Java 21 TESTS 7 483 11776000
317685579 man-ray D April 29, 2025, 1:32 a.m. OK Java 21 TESTS 7 483 54579200
317648155 _firstexception D April 28, 2025, 4:25 p.m. OK Java 21 TESTS 7 483 156569600
317643912 Abhishek.B D April 28, 2025, 4:15 p.m. OK Java 21 TESTS 7 500 17305600
317643053 rupeshpatelcf D April 28, 2025, 4:13 p.m. OK Java 21 TESTS 7 514 29184000
317645429 Coder_GEAR5 D April 28, 2025, 4:18 p.m. OK Java 21 TESTS 7 531 24985600
317651117 _firstexception D April 28, 2025, 4:32 p.m. OK Java 21 TESTS 7 531 157696000
317692558 akshatsaxena552004.ss D April 29, 2025, 4:07 a.m. OK Java 21 TESTS 7 624 46489600
317697901 yang_wei D April 29, 2025, 5:35 a.m. OK Java 21 TESTS 7 639 57856000
317671207 huhansan D April 28, 2025, 7:48 p.m. OK Java 8 TESTS 7 389 25497600
317651061 yashu_rai D April 28, 2025, 4:32 p.m. OK Java 8 TESTS 7 421 28979200
317691576 abhayrajnegi0416 D April 29, 2025, 3:48 a.m. OK Java 8 TESTS 7 655 50176000
317693406 only_forward_ D April 29, 2025, 4:25 a.m. OK Java 8 TESTS 7 733 5427200
317641772 rutul21 D April 28, 2025, 4:09 p.m. OK Java 8 TESTS 7 796 7987200
317693161 only_forward_ D April 29, 2025, 4:20 a.m. OK Java 8 TESTS 7 812 5427200
317650323 kshitij777 D April 28, 2025, 4:30 p.m. OK Java 8 TESTS 7 843 17100800
317686416 naitik.ntn2001 D April 29, 2025, 1:54 a.m. OK Java 8 TESTS 7 874 39116800
317649315 Artistic_code D April 28, 2025, 4:28 p.m. OK Java 8 TESTS 7 1015 139059200
317643233 sujal-17 D April 28, 2025, 4:13 p.m. OK Java 8 TESTS 7 1046 72601600
317646102 dioxkjpde D April 28, 2025, 4:20 p.m. OK Mono C# TESTS 7 437 49971200
317650351 gr_priyk D April 28, 2025, 4:30 p.m. OK PyPy 3 TESTS 7 687 61747200
317644203 fenil123 D April 28, 2025, 4:15 p.m. OK PyPy 3 TESTS 7 812 92160000
317698872 yiwangwuqian D April 29, 2025, 5:47 a.m. OK PyPy 3 TESTS 7 952 101990400
317645096 suhcir__kalra08 D April 28, 2025, 4:18 p.m. OK PyPy 3 TESTS 7 1437 83558400
317674059 shubhamgoel0711 D April 28, 2025, 8:32 p.m. OK PyPy 3 TESTS 7 1624 176230400
317646519 hugoback01 D April 28, 2025, 4:21 p.m. OK PyPy 3 TESTS 7 1639 36044800
317672573 Code.Virtuoso D April 28, 2025, 8:09 p.m. OK PyPy 3 TESTS 7 1843 189747200
317642588 ossau D April 28, 2025, 4:12 p.m. OK PyPy 3-64 TESTS 7 374 73625600
317658010 pyorz D April 28, 2025, 5:30 p.m. OK PyPy 3-64 TESTS 7 389 116736000
317657942 Om_Singh_ D April 28, 2025, 5:30 p.m. OK PyPy 3-64 TESTS 7 390 118784000
317667604 golomb D April 28, 2025, 7:07 p.m. OK PyPy 3-64 TESTS 7 421 138956800
317682280 randombernie D April 28, 2025, 11:51 p.m. OK PyPy 3-64 TESTS 7 436 77414400
317657758 Om_Singh_ D April 28, 2025, 5:28 p.m. OK PyPy 3-64 TESTS 7 467 162201600
317644962 conqueror_of_mishai D April 28, 2025, 4:17 p.m. OK PyPy 3-64 TESTS 7 515 115302400
317669811 azerbenmed1730 D April 28, 2025, 7:31 p.m. OK PyPy 3-64 TESTS 7 515 122163200
317666600 shash4321 D April 28, 2025, 6:56 p.m. OK PyPy 3-64 TESTS 7 530 61542400
317657694 Om_Singh_ D April 28, 2025, 5:28 p.m. OK PyPy 3-64 TESTS 7 530 161996800
317646670 ruhittanvir14 D April 28, 2025, 4:21 p.m. OK Python 3 TESTS 7 1031 93081600
317644207 Nurmyrat D April 28, 2025, 4:15 p.m. OK Python 3 TESTS 7 1155 66252800
317671977 akarsh_jain05 D April 28, 2025, 7:59 p.m. OK Python 3 TESTS 7 1264 112230400
317644323 Jaardo D April 28, 2025, 4:16 p.m. OK Python 3 TESTS 7 1390 87244800
317641737 2024liuzheng D April 28, 2025, 4:09 p.m. OK Python 3 TESTS 7 1405 96665600
317652054 jashwanthnani D April 28, 2025, 4:34 p.m. OK Python 3 TESTS 7 1499 108339200
317642775 vaibhav_fusion D April 28, 2025, 4:12 p.m. OK Python 3 TESTS 7 1577 89804800
317650153 FyReX_KING635 D April 28, 2025, 4:30 p.m. OK Python 3 TESTS 7 1593 86016000
317677508 DesiCoder D April 28, 2025, 9:41 p.m. OK Python 3 TESTS 7 1702 88678400
317647709 Thowfiq_Rahman_A D April 28, 2025, 4:24 p.m. OK Python 3 TESTS 7 1749 94310400
317644891 dom7171 D April 28, 2025, 4:17 p.m. OK Rust 2021 TESTS 7 156 28672000
317689285 v1kasja1swal D April 29, 2025, 3:02 a.m. OK Rust 2021 TESTS 7 156 44851200
317650706 Sai_Jaswanth07 D April 28, 2025, 4:31 p.m. OK Rust 2021 TESTS 7 171 15462400
317678570 123gjweq2 D April 28, 2025, 10:09 p.m. OK Rust 2021 TESTS 7 265 26828800
317694320 silicalet D April 29, 2025, 4:42 a.m. OK Rust 2021 TESTS 7 265 85094400
317657300 vstiff D April 28, 2025, 5:24 p.m. OK Rust 2021 TESTS 7 296 83558400

remove filters

Back to search problems