Kotlin Heroes: Practice 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
1532 Kotlin Heroes: Practice 7 FINISHED False 604800 152036723 June 22, 2021, 1:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 392 ) E Good Array PROGRAMMING *special

Let's call an array good if there is an element in the array that equals to the sum of all other elements. For example, the array (a=1, 3, 3, 7) is good because there is the element (a_4=7) which equals to the sum (1 + 3 + 3). You are given an array (a) consisting of (n) integers. Your task is to print all indices (j) of this array such that after removing the (j)-th element from the array it will be good (let's call such indices nice ). For example, if (a=8, 3, 5, 2), the nice indices are (1) and (4): if you remove (a_1), the array will look like (3, 5, 2) and it is good ; if you remove (a_4), the array will look like (8, 3, 5) and it is good . You have to consider all removals independently , i. e. remove the element, check if the resulting array is good , and return the element into the array. The first line of the input contains one integer (n) ((2 \le n \le 2 \cdot 10^5)) — the number of elements in the array (a). The second line of the input contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le 10^6)) — elements of the array (a). In the first line print one integer (k) — the number of indices (j) of the array (a) such that after removing the (j)-th element from the array it will be good (i.e. print the number of the nice indices). In the second line print (k) distinct integers (j_1, j_2, \dots, j_k) in any order — nice indices of the array (a). If there are no such indices in the array (a), just print (0) in the first line and leave the second line empty or do not print it at all. In the first example you can remove any element with the value (2) so the array will look like (5, 1, 2, 2). The sum of this array is (10) and there is an element equals to the sum of remaining elements ((5 = 1 + 2 + 2)). In the second example you can remove (8) so the array will look like (3, 5, 2). The sum of th

Tutorials

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
120358435 Mr.Try_Harder E June 23, 2021, 10:35 a.m. OK Kotlin TESTS 101 155 0
120310902 Skypiea E June 22, 2021, 4:52 p.m. OK Kotlin TESTS 101 155 3584000
120729555 aedificator E June 27, 2021, 11:06 a.m. OK Kotlin TESTS 101 155 6348800
120301487 Spheniscine E June 22, 2021, 2:45 p.m. OK Kotlin TESTS 101 171 5324800
120356156 jainmilind E June 23, 2021, 10 a.m. OK Kotlin TESTS 101 186 4505600
120302230 Fortin E June 22, 2021, 2:53 p.m. OK Kotlin TESTS 101 186 6144000
120641467 9646516 E June 26, 2021, 6:22 a.m. OK Kotlin TESTS 101 186 6656000
120871579 DeadPillow E June 29, 2021, 11:53 a.m. OK Kotlin TESTS 101 187 6144000
120308380 Ra16bit E June 22, 2021, 4:07 p.m. OK Kotlin TESTS 101 202 5324800
120384610 fung19971115 E June 23, 2021, 4:29 p.m. OK Kotlin TESTS 101 202 7782400

remove filters

Back to search problems