Kotlin Heroes: Episode 14

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
2199 Kotlin Heroes: Episode 14 FINISHED False 9000 3943523 March 2, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 179 ) E Supersequence PROGRAMMING *special binary search greedy

An array (a) is called a subsequence of an array (b) if some elements can be removed from array (b) (possibly all, possibly none) to obtain the array (a). You are given an array (a = a_1, a_2, \dots, a_n). We call an array (b = b_1, b_2, \dots, b_m) beautiful if: (a) is a subsequence of (b); for each (i) from (1) to (m-1), the elements (b_i) and (b_{i+1}) differ by exactly (1) (that is, (|b_i - b_{i+1}| = 1)); among all arrays that satisfy these two requirements, the length of (b) is minimum. You have to process (q) queries. In the (i)-th query, a single integer (x_i) is given. Your task is as follows: if (x_i) is greater than the minimum possible number of elements in a beautiful array, print (-1); otherwise, if the same number occupies position (x_i) in all beautiful arrays, print that number; otherwise, print (0). The first line contains two integers (n) and (q) ((1 \le n, q \le 2 \cdot 10^5)). The second line contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le 10^9)). The third line contains (q) integers (x_1, x_2, \dots, x_q) ((1 \le x_i \le 10^{18})). For each query, print a single integer — the answer to it.

Tutorials

151783

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
365122059 hellovir E March 2, 2026, 5:04 p.m. OK Kotlin 1.7 TESTS 22 390 14540800
365111861 Sumit_Mahajan E March 2, 2026, 3:45 p.m. OK Kotlin 1.7 TESTS 22 406 17305600
365113898 Duskshard E March 2, 2026, 4:01 p.m. OK Kotlin 1.7 TESTS 22 406 18227200
365119257 ujjawalmishra816 E March 2, 2026, 4:43 p.m. OK Kotlin 1.7 TESTS 22 437 19968000
365108227 khba E March 2, 2026, 3:21 p.m. OK Kotlin 1.7 TESTS 22 437 20172800
365137553 gb2955381 E March 2, 2026, 7:23 p.m. OK Kotlin 1.7 TESTS 22 437 21811200
365113487 yatuoximeng E March 2, 2026, 3:57 p.m. OK Kotlin 1.7 TESTS 22 453 14950400
365149869 last_theorem E March 2, 2026, 10:10 p.m. OK Kotlin 1.7 TESTS 22 468 18739200
365108668 kriradhaks E March 2, 2026, 3:23 p.m. OK Kotlin 1.7 TESTS 22 562 22630400
365119479 RitikaBaliyan8 E March 2, 2026, 4:45 p.m. OK Kotlin 1.7 TESTS 22 578 52428800
365108277 p0tato E March 2, 2026, 3:21 p.m. OK Kotlin 1.9 TESTS 22 453 15564800
365110334 Hanlabong E March 2, 2026, 3:35 p.m. OK Kotlin 1.9 TESTS 22 468 33894400
365106201 __jk__ E March 2, 2026, 3:08 p.m. OK Kotlin 1.9 TESTS 22 484 0
365115247 hot E March 2, 2026, 4:12 p.m. OK Kotlin 1.9 TESTS 22 671 40448000
365111776 ktobarsuk E March 2, 2026, 3:45 p.m. OK Kotlin 1.9 TESTS 22 671 41676800
365114583 zornlemma E March 2, 2026, 4:07 p.m. OK Kotlin 1.9 TESTS 22 718 32563200
365109353 yudedako E March 2, 2026, 3:28 p.m. OK Kotlin 1.9 TESTS 22 734 33484800
365117477 snnr E March 2, 2026, 4:30 p.m. OK Kotlin 1.9 TESTS 22 750 33792000
365105424 BucketPotato E March 2, 2026, 3:03 p.m. OK Kotlin 1.9 TESTS 22 875 36147200
365107544 irmuun E March 2, 2026, 3:16 p.m. OK Kotlin 1.9 TESTS 22 906 33587200
365110678 Joskmo E March 2, 2026, 3:37 p.m. OK Kotlin 2.2 TESTS 22 218 23654400
365164283 thanhnguyxn07 E March 3, 2026, 3:27 a.m. OK Kotlin 2.2 TESTS 22 218 23756800
365121779 BKkoi E March 2, 2026, 5:02 p.m. OK Kotlin 2.2 TESTS 22 218 32563200
365119896 BKkoi E March 2, 2026, 4:48 p.m. OK Kotlin 2.2 TESTS 22 218 32665600
365112814 SINNOCENT E March 2, 2026, 3:52 p.m. OK Kotlin 2.2 TESTS 22 250 25600000
365110627 E49869826 E March 2, 2026, 3:37 p.m. OK Kotlin 2.2 TESTS 22 265 25292800
365112990 Nikrien E March 2, 2026, 3:54 p.m. OK Kotlin 2.2 TESTS 22 265 32256000
365119623 I_love_GSNQK E March 2, 2026, 4:46 p.m. OK Kotlin 2.2 TESTS 22 296 24064000
365115203 PKsilent E March 2, 2026, 4:12 p.m. OK Kotlin 2.2 TESTS 22 312 44134400
365107475 lanindu2008 E March 2, 2026, 3:16 p.m. OK Kotlin 2.2 TESTS 22 343 44236800

remove filters

Back to search problems