Kotlin Heroes: Practice 8

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
1570 Kotlin Heroes: Practice 8 FINISHED False 518400 143310323 Oct. 1, 2021, 1:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 294 ) C Shooting PROGRAMMING *special greedy implementation

Recently Vasya decided to improve his pistol shooting skills. Today his coach offered him the following exercise. He placed (n) cans in a row on a table. Cans are numbered from left to right from (1) to (n). Vasya has to knock down each can exactly once to finish the exercise. He is allowed to choose the order in which he will knock the cans down. Vasya knows that the durability of the (i)-th can is (a_i). It means that if Vasya has already knocked (x) cans down and is now about to start shooting the (i)-th one, he will need ((a_i \cdot x + 1)) shots to knock it down. You can assume that if Vasya starts shooting the (i)-th can, he will be shooting it until he knocks it down. Your task is to choose such an order of shooting so that the number of shots required to knock each of the (n) given cans down exactly once is minimum possible. The first line of the input contains one integer (n) ((2 \le n \le 1\,000)) — the number of cans. The second line of the input contains the sequence (a_1, a_2, \dots, a_n) ((1 \le a_i \le 1\,000)), where (a_i) is the durability of the (i)-th can. In the first line print the minimum number of shots required to knock each of the (n) given cans down exactly once. In the second line print the sequence consisting of (n) distinct integers from (1) to (n) — the order of indices of cans that minimizes the number of shots required. If there are several answers, you can print any of them. In the first example Vasya can start shooting from the first can. He knocks it down with the first shot because he haven't knocked any other cans down before. After that he has to shoot the third can. To knock it down he shoots (20 \cdot 1 + 1 = 21) times. After that only second can remains. To knock it down Vasya shoots (10 \cdot 2 + 1 = 21) times. So the total number of shots is (1 + 21 + 21 = 43). In the second example the order of shooting does not matter bec

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
130533254 BruteForcee C Oct. 2, 2021, 7:02 a.m. OK Kotlin 1.4 TESTS 8 108 20992000
130845604 Ra16bit C Oct. 5, 2021, 12:02 a.m. OK Kotlin 1.4 TESTS 8 108 21094400
131033310 Avatar C Oct. 7, 2021, 5:53 a.m. OK Kotlin 1.4 TESTS 8 109 20889600
130639737 crimsonred C Oct. 3, 2021, 9:42 a.m. OK Kotlin 1.4 TESTS 8 109 22630400
130496789 smahajan54842 C Oct. 1, 2021, 6:25 p.m. OK Kotlin 1.4 TESTS 8 109 22630400
130886808 shnirelman C Oct. 5, 2021, 12:03 p.m. OK Kotlin 1.4 TESTS 8 124 614400
130480910 TAoz1 C Oct. 1, 2021, 3:38 p.m. OK Kotlin 1.4 TESTS 8 124 614400
130817878 madlogic C Oct. 4, 2021, 3:18 p.m. OK Kotlin 1.4 TESTS 8 124 20889600
130592189 Tony1234 C Oct. 2, 2021, 6:35 p.m. OK Kotlin 1.4 TESTS 8 124 20992000
130485100 Dstoical C Oct. 1, 2021, 4:22 p.m. OK Kotlin 1.4 TESTS 8 124 20992000
130588042 avdim C Oct. 2, 2021, 5:38 p.m. OK Kotlin 1.5 TESTS 8 186 26214400
131052661 Vercingetorix C Oct. 7, 2021, 10:02 a.m. OK Kotlin 1.5 TESTS 8 187 26214400
130741253 Raftyy C Oct. 3, 2021, 9:25 p.m. OK Kotlin 1.5 TESTS 8 187 26214400
130667831 roctes7 C Oct. 3, 2021, 2:41 p.m. OK Kotlin 1.5 TESTS 8 187 26214400
130575437 achilleus C Oct. 2, 2021, 3:04 p.m. OK Kotlin 1.5 TESTS 8 187 26214400
130616004 lucifer1004 C Oct. 3, 2021, 5:17 a.m. OK Kotlin 1.5 TESTS 8 187 26316800
130577424 thumannw C Oct. 2, 2021, 3:25 p.m. OK Kotlin 1.5 TESTS 8 187 27443200
130539221 MrOtter C Oct. 2, 2021, 8:09 a.m. OK Kotlin 1.5 TESTS 8 202 204800
131054356 9646516 C Oct. 7, 2021, 10:25 a.m. OK Kotlin 1.5 TESTS 8 202 25804800
130735892 basfor2022 C Oct. 3, 2021, 7:29 p.m. OK Kotlin 1.5 TESTS 8 202 25907200

remove filters

Back to search problems