Kotlin Heroes: Episode 7

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
1533 Kotlin Heroes: Episode 7 FINISHED False 9000 106845899 June 29, 2021, 2:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 473 ) C Sweets PROGRAMMING *special data structures implementation

B"Anya came to her friend's birthday party. There are n delicious sweets on a circle table (for convenience, we will number them from 1 to n in clockwise direction). For each of the sweets, it is known whether Anya likes it or not. Anya decided that she should eat all the sweets that are on the table, and she likes them. However, eating all the sweets in some random order is too boring. Therefore, Anya came up with a game that will make the process of eating sweets more interesting. The game is played according to the following rules: For example, let 6 sweets be arranged in a circle, Anya likes sweets 4 , 5 and 6 , k = 4 . Then the game goes as follows: Your task is to calculate the number of sweets that Anya will eat. The first line contains a single integer t ( 1 <= t <= 5000 ) -- the number of test cases. The first line of each test case contains two integers n and k ( 1 <= k <= n <= 5000 ) -- the number of sweets and the parameter k . The next line contains the string s , where s_i = 1 if Anya likes i -th sweet, and s_i = 0 otherwise. It is guaranteed that the sum of n over all test cases does not exceed 5000 . For each test case, print one integer -- the number of sweets that Anya will eat. The first test case of the example is described in the statement. "...

Tutorials

Kotlin Heroes 7 — Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
120896348 om_1999 C June 29, 2021, 4:42 p.m. OK Kotlin TESTS 17 109 0
120885689 Egor C June 29, 2021, 2:52 p.m. OK Kotlin TESTS 17 109 0
120884098 xiaowuc1 C June 29, 2021, 2:40 p.m. OK Kotlin TESTS 17 109 0
120891170 elena_d C June 29, 2021, 3:43 p.m. OK Kotlin TESTS 17 124 0
120891007 korilin.dev C June 29, 2021, 3:42 p.m. OK Kotlin TESTS 17 124 0
120889115 I_love_Avicii C June 29, 2021, 3:23 p.m. OK Kotlin TESTS 17 124 0
120888285 galaxy_dl C June 29, 2021, 3:15 p.m. OK Kotlin TESTS 17 124 0
120887706 Jman C June 29, 2021, 3:09 p.m. OK Kotlin TESTS 17 124 0
120886601 man.yasakov C June 29, 2021, 3 p.m. OK Kotlin TESTS 17 124 0
120886296 firiexp C June 29, 2021, 2:57 p.m. OK Kotlin TESTS 17 124 0

remove filters

Back to search problems