Kotlin Heroes: Episode 13

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
2141 Kotlin Heroes: Episode 13 FINISHED False 9000 18717923 Sept. 12, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 136 ) F Array Reduction PROGRAMMING *special greedy

You are given an array (a) containing (n) integers. In one operation, you can choose some elements from this array and remove them. However, the elements you choose must meet one of the following conditions: either all chosen elements are equal; or there are no two equal chosen elements. Note that if you choose only (1) element to remove, it automatically meets these conditions. For example, if (a = \{1, 2, 1, 1, 3\}), some of the possible elements you can remove in one operation are: the (1)-st element; the (1)-st and the (3)-rd element; the (1)-st, the (3)-rd and the (4)-th element; the (3)-rd and the (4)-th element; the (2)-nd, the (4)-th and the (5)-th element; and many others. However, you cannot choose the (2)-nd, the (3)-rd and the (4)-th element because the (2)-nd element is not equal to the (4)-th, but the (3)-rd element is equal to the (4)-th. For each (x) from (0) to (n - 1), you have to calculate the minimum number of operations required to decrease the size of the array to exactly (x). The first line contains one integer (t) ((1 \le t \le 10^4)) — the number of test cases. Each test case consists of two lines: the first line contains one integer (n) ((1 \le n \le 3 \cdot 10^5)) — the size of the array; the second line contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le n)) — the array itself. Additional constraint on the input: the sum of (n) over all test cases does not exceed (3 \cdot 10^5). For each test case, print (n) integers (c_0, c_1, \dots, c_{n-1}), where (c_i) is the minimum number of operations required to reduce the size of the array to exactly (i). In the first example, the answer can be obtained as follows: (c_{0} = 3): remove (a_{8}, a_{9}, a_{10}, a_{11}); then remove (a_{1}, a_{2}, a_{3}, a_{4}); then remove (a_{5}, a_{6}, a_{7}); (c_{1} = 3):

Tutorials

Kotlin Heroes 13 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
338236040 GNU F Sept. 12, 2025, 3:41 p.m. OK Kotlin 1.7 TESTS 36 468 22220800
338237772 gageyaj543 F Sept. 12, 2025, 3:52 p.m. OK Kotlin 1.7 TESTS 36 499 44544000
338247998 Nxxlt F Sept. 12, 2025, 5:04 p.m. OK Kotlin 1.7 TESTS 36 531 28672000
338236850 marcopolo_ F Sept. 12, 2025, 3:46 p.m. OK Kotlin 1.7 TESTS 36 577 63590400
338234075 kumargaurav993901 F Sept. 12, 2025, 3:30 p.m. OK Kotlin 1.7 TESTS 36 578 38195200
338275918 VaHiX F Sept. 12, 2025, 10:14 p.m. OK Kotlin 1.7 TESTS 36 655 19046400
338234747 dipanshu_raj F Sept. 12, 2025, 3:34 p.m. OK Kotlin 1.7 TESTS 36 655 63385600
338230760 potato167 F Sept. 12, 2025, 3:11 p.m. OK Kotlin 1.7 TESTS 36 655 88268800
338236611 potatoo F Sept. 12, 2025, 3:45 p.m. OK Kotlin 1.7 TESTS 36 656 46182400
338244856 manhmkl87 F Sept. 12, 2025, 4:41 p.m. OK Kotlin 1.7 TESTS 36 671 66764800
338245002 dpatel_108 F Sept. 12, 2025, 4:42 p.m. OK Kotlin 1.9 TESTS 36 186 2457600
338238866 Iplay1.d4 F Sept. 12, 2025, 3:59 p.m. OK Kotlin 1.9 TESTS 36 217 0
338247384 NHiL F Sept. 12, 2025, 5 p.m. OK Kotlin 1.9 TESTS 36 280 0
338232240 inukurthi_srihari F Sept. 12, 2025, 3:19 p.m. OK Kotlin 1.9 TESTS 36 281 8089600
338239874 __jk__ F Sept. 12, 2025, 4:07 p.m. OK Kotlin 1.9 TESTS 36 296 921600
338236452 MDelPiero F Sept. 12, 2025, 3:44 p.m. OK Kotlin 1.9 TESTS 36 421 18432000
338234122 Ashar-Usmani F Sept. 12, 2025, 3:30 p.m. OK Kotlin 1.9 TESTS 36 421 29081600
338247134 MohamedSaeed F Sept. 12, 2025, 4:58 p.m. OK Kotlin 1.9 TESTS 36 452 41984000
338227992 tourist F Sept. 12, 2025, 2:56 p.m. OK Kotlin 1.9 TESTS 36 499 30720000
338261197 yudedako F Sept. 12, 2025, 6:59 p.m. OK Kotlin 1.9 TESTS 36 546 29184000
338236873 O3_Tester F Sept. 12, 2025, 3:46 p.m. OK Kotlin 2.2 TESTS 36 203 0
338240376 i_am_wa F Sept. 12, 2025, 4:10 p.m. OK Kotlin 2.2 TESTS 36 218 0
338229619 _raaghav_22 F Sept. 12, 2025, 3:04 p.m. OK Kotlin 2.2 TESTS 36 249 0
338243399 abhaykumar70953 F Sept. 12, 2025, 4:31 p.m. OK Kotlin 2.2 TESTS 36 249 6758400
338245805 sunnydev F Sept. 12, 2025, 4:48 p.m. OK Kotlin 2.2 TESTS 36 264 8396800
338237174 roushankr090 F Sept. 12, 2025, 3:48 p.m. OK Kotlin 2.2 TESTS 36 280 5427200
338239144 p4106650 F Sept. 12, 2025, 4:01 p.m. OK Kotlin 2.2 TESTS 36 280 7372800
338243081 daukhoi F Sept. 12, 2025, 4:28 p.m. OK Kotlin 2.2 TESTS 36 280 7475200
338240092 malo223 F Sept. 12, 2025, 4:08 p.m. OK Kotlin 2.2 TESTS 36 296 9216000
338244864 lto5 F Sept. 12, 2025, 4:41 p.m. OK Kotlin 2.2 TESTS 36 374 0

remove filters

Back to search problems