Kotlin Heroes: Episode 3

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
1297 Kotlin Heroes: Episode 3 FINISHED False 9000 149012699 Feb. 27, 2020, 1:35 p.m.

Problems

Solved$
Index
Name
Type
Tags
Community Tag
Rating
( 262 ) D Bonus Distribution PROGRAMMING *special binary search greedy sortings

B"For the first time, Polycarp's startup ended the year with a profit! Now he is about to distribute k burles as a bonus among n employees. It is known that the current salary of the i -th employee is a_i and all the values of a_i in the company are different. Polycarp wants to distribute the k burles between n employees so this month the i -th employee will be paid not a_i , but a_i+d_i ( d_i ge 0 , d_i is an integer), where d_i is the bonus for the i -th employee. Of course, d_1+d_2+ ... +d_n=k . Polycarp will follow two rules for choosing the values d_i : Help Polycarp decide the non-negative integer bonuses d_i such that: Help Polycarp and print any of the possible answers d_1, d_2, ... , d_n . The first line contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases in the input. Then t test cases follow. The first line of each test case contains two integers n and k ( 1 <= n <= 10^5 , 1 <= k <= 10^9 ) -- the number of employees and the total bonus. The second line of each test case contains n different integers a_1, a_2, ... , a_n ( 1 <= a_i <= 10^9 ), where a_i is the current salary of the i -th employee. It is guaranteed that the sum of all n values in the input does not exceed 10^5 . Print the answers to t test cases in the order they appear in the input. Print each answer as a sequence of non-negative integers d_1, d_2, ... , d_n . If there are several answers, print any of them. "...

Tutorials

Kotlin Heroes: Episode 3 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
71979815 dalt D Feb. 27, 2020, 2:17 p.m. OK Kotlin TESTS 17 155 21401600
71978626 eatmore D Feb. 27, 2020, 2:04 p.m. OK Kotlin TESTS 17 186 0
72025153 Ebrahim_Emon D Feb. 28, 2020, 9:09 a.m. OK Kotlin TESTS 17 187 0
71977507 Egor D Feb. 27, 2020, 1:53 p.m. OK Kotlin TESTS 17 187 0
71979127 gwq2017 D Feb. 27, 2020, 2:09 p.m. OK Kotlin TESTS 17 202 409600
71984610 avm D Feb. 27, 2020, 3:15 p.m. OK Kotlin TESTS 17 202 614400
71982376 kenkoooo D Feb. 27, 2020, 2:46 p.m. OK Kotlin TESTS 17 217 0
71979721 icebound D Feb. 27, 2020, 2:15 p.m. OK Kotlin TESTS 17 218 102400
71987482 iankury D Feb. 27, 2020, 3:53 p.m. OK Kotlin TESTS 17 233 409600
71982594 yakamoto D Feb. 27, 2020, 2:48 p.m. OK Kotlin TESTS 17 233 3072000

remove filters

Back to search problems