Kotlin Heroes: Episode 1

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
1170 Kotlin Heroes: Episode 1 FINISHED False 9000 178385087 May 28, 2019, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 49 ) H Longest Saw PROGRAMMING *special constructive algorithms

B'You are given the sequence a_1, a_2, ... , a_n . You can choose any subset of elements and then reorder them to create a "saw". The sequence b_1, b_2, ... , b_m is called a "saw" if the elements satisfy one of the following series of inequalities: b_1>b_2<b_3>b_4< ... or b_1<b_2>b_3<b_4> ... . Find the longest saw which can be obtained from a given array. Note that both the given sequence a and the required saw b can contain duplicated (non-unique) values. The first line contains an integer t ( 1 <= t <= 10^5 ) -- the number of test cases in the input. Then the descriptions of the t test cases follow. Each test case begins with a line containing integer n ( 1 <= n <= 2 cdot10^5 ). Then a line containing n integers a_1, a_2, ... , a_n ( 1 <= a_i <= 10^9 ) follows. It 's guaranteed that sum{n} doesn 't exceed 2 cdot 10^5 . For each test case, print two lines: print the length of the longest saw in the first line, and the saw itself in the second line. If there are several solutions, print any of them. '...

Tutorials

Kotlin Heroes Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
54763278 300iq H May 28, 2019, 4:24 p.m. OK Kotlin TESTS 54 202 4403200
54761385 eatmore H May 28, 2019, 3:56 p.m. OK Kotlin TESTS 54 202 4403200
55109240 TOXait H June 5, 2019, 5:16 a.m. OK Kotlin TESTS 54 217 4403200
55610775 ReaLNero1 H June 16, 2019, 5:35 a.m. OK Kotlin TESTS 54 218 4403200
54761813 Petr H May 28, 2019, 4:02 p.m. OK Kotlin TESTS 54 218 4403200
55279353 NighTurs H June 7, 2019, 10:20 p.m. OK Kotlin TESTS 54 265 17510400
54767078 DmitryGrigorev H May 28, 2019, 5:39 p.m. OK Kotlin TESTS 54 311 5427200
58337625 Sali_adelkhah H Aug. 5, 2019, 12:04 p.m. OK Kotlin TESTS 54 451 18124800
54764806 Deemo H May 28, 2019, 4:50 p.m. OK Kotlin TESTS 54 467 19763200
54760261 tourist H May 28, 2019, 3:40 p.m. OK Kotlin TESTS 54 482 18124800

remove filters

Back to search problems