Educational Codeforces Round 117 (Rated for Div. 2)

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
1612 Educational Codeforces Round 117 (Rated for Div. 2) FINISHED False 7200 138831923 Nov. 22, 2021, 9:35 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 997 ) G Max Sum Array PROGRAMMING combinatorics constructive algorithms greedy sortings

You are given an array c = [c_1, c_2, ... , c_m] . An array a = [a_1, a_2, ... , a_n] is constructed in such a way that it consists of integers 1, 2, ... , m , and for each i in [1,m] , there are exactly c_i occurrences of integer i in a . So, the number of elements in a is exactly sum limits_{i=1}^{m} c_i . Let's define for such array a the value f(a) as f(a) = sum_{ substack{1 <= i < j <= n a_i = a_j}}{j - i}. In other words, f(a) is the total sum of distances between all pairs of equal elements. Your task is to calculate the maximum possible value of f(a) and the number of arrays yielding the maximum possible value of f(a) . Two arrays are considered different, if elements at some position differ. The first line contains a single integer m ( 1 <= m <= 5 cdot 10^5 ) -- the size of the array c . The second line contains m integers c_1, c_2, ... , c_m ( 1 <= c_i <= 10^6 ) -- the array c . Print two integers -- the maximum possible value of f(a) and the number of arrays a with such value. Since both answers may be too large, print them modulo 10^9 + 7 . In the first example, all possible arrays a are permutations of [1, 2, 3, 4, 5, 6] . Since each array a will have f(a) = 0 , so maximum value is f(a) = 0 and there are 6! = 720 such arrays. In the second example, the only possible array consists of 10^6 ones and its f(a) = sum limits_{1 <= i < j <= 10^6}{j - i} = 166 ,666 ,666 ,666 ,500 ,000 and 166 ,666 ,666 ,666 ,500 ,000 bmod{10^9 + 7} = 499 ,833 ,345 .

Tutorials

97164

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
136527186 eecs G Nov. 22, 2021, 2:35 p.m. OK GNU C++14 TESTS 21 217 24064000
136468423 LucaSeri G Nov. 22, 2021, 11:28 a.m. OK GNU C++14 TESTS 21 218 18022400
136570626 _ztyqwq G Nov. 23, 2021, 5:43 a.m. OK GNU C++14 TESTS 21 234 20070400
136477512 bit_liyiwen G Nov. 22, 2021, 11:42 a.m. OK GNU C++14 TESTS 21 249 28057600
136485813 ButterCake G Nov. 22, 2021, 12:53 p.m. OK GNU C++14 TESTS 21 264 11980800
136480076 AlexWangr G Nov. 22, 2021, 12:01 p.m. OK GNU C++14 TESTS 21 264 14028800
136564143 XiEn1847 G Nov. 23, 2021, 3:23 a.m. OK GNU C++14 TESTS 21 265 20070400
136470285 harryzhr G Nov. 22, 2021, 11:32 a.m. OK GNU C++14 TESTS 21 265 24064000
136564053 XiEn1847 G Nov. 23, 2021, 3:21 a.m. OK GNU C++14 TESTS 21 280 28057600
136466780 1946037404 G Nov. 22, 2021, 11:24 a.m. OK GNU C++14 TESTS 21 296 24064000
136524566 Shanks G Nov. 22, 2021, 2:09 p.m. OK GNU C++17 TESTS 21 202 7987200
136471068 pikel_rik G Nov. 22, 2021, 11:34 a.m. OK GNU C++17 TESTS 21 202 10035200
136466307 HDUPCA G Nov. 22, 2021, 11:23 a.m. OK GNU C++17 TESTS 21 202 16076800
136480442 zhaosongwen G Nov. 22, 2021, 12:03 p.m. OK GNU C++17 TESTS 21 234 10035200
136486857 Enilrats G Nov. 22, 2021, 1:02 p.m. OK GNU C++17 TESTS 21 234 28057600
136528200 P2N2T G Nov. 22, 2021, 2:46 p.m. OK GNU C++17 TESTS 21 249 11161600
136485951 DerekFeng G Nov. 22, 2021, 12:54 p.m. OK GNU C++17 TESTS 21 249 12083200
136536772 abc864197532 G Nov. 22, 2021, 4:30 p.m. OK GNU C++17 TESTS 21 249 16076800
136540420 262226781 G Nov. 22, 2021, 5:20 p.m. OK GNU C++17 TESTS 21 249 16179200
136521712 1015634 G Nov. 22, 2021, 1:42 p.m. OK GNU C++17 TESTS 21 249 24064000
136537980 fallleaves01 G Nov. 22, 2021, 4:45 p.m. OK GNU C++17 (64) TESTS 21 46 8089600
136480449 allay G Nov. 22, 2021, 12:03 p.m. OK GNU C++17 (64) TESTS 21 108 24064000
136557970 basic_string G Nov. 22, 2021, 11:57 p.m. OK GNU C++17 (64) TESTS 21 139 11980800
136535575 huangxiaohua G Nov. 22, 2021, 4:14 p.m. OK GNU C++17 (64) TESTS 21 139 24166400
136479689 cuiaoxiang G Nov. 22, 2021, 11:58 a.m. OK GNU C++17 (64) TESTS 21 140 10240000
136526908 Turkey G Nov. 22, 2021, 2:32 p.m. OK GNU C++17 (64) TESTS 21 140 12083200
136480602 Lucina G Nov. 22, 2021, 12:05 p.m. OK GNU C++17 (64) TESTS 21 155 22016000
136563375 gvihvo G Nov. 23, 2021, 3:04 a.m. OK GNU C++17 (64) TESTS 21 156 10035200
136520652 emthrm G Nov. 22, 2021, 1:31 p.m. OK GNU C++17 (64) TESTS 21 156 14028800
136560214 QwQcOrZ G Nov. 23, 2021, 1:29 a.m. OK GNU C++17 (64) TESTS 21 171 11980800
136478301 risujiroh G Nov. 22, 2021, 11:47 a.m. OK GNU C++20 (64) TESTS 21 46 8089600
136570162 YLWang G Nov. 23, 2021, 5:35 a.m. OK GNU C++20 (64) TESTS 21 77 24166400
136483294 dorijanlendvaj G Nov. 22, 2021, 12:30 p.m. OK GNU C++20 (64) TESTS 21 93 16076800
136477921 chctxdy68 G Nov. 22, 2021, 11:45 a.m. OK GNU C++20 (64) TESTS 21 109 16076800
136466114 lapfsjg G Nov. 22, 2021, 11:22 a.m. OK GNU C++20 (64) TESTS 21 109 24064000
136538788 kmjp G Nov. 22, 2021, 4:56 p.m. OK GNU C++20 (64) TESTS 21 109 28262400
136526098 Esquire G Nov. 22, 2021, 2:24 p.m. OK GNU C++20 (64) TESTS 21 124 12083200
136524484 tczzz G Nov. 22, 2021, 2:09 p.m. OK GNU C++20 (64) TESTS 21 124 16076800
136547394 ARINOOR G Nov. 22, 2021, 7:09 p.m. OK GNU C++20 (64) TESTS 21 139 30310400
136523643 tczzz G Nov. 22, 2021, 2:01 p.m. OK GNU C++20 (64) TESTS 21 140 16076800
136543387 OLOGY G Nov. 22, 2021, 6:02 p.m. OK PyPy 2 TESTS 21 748 46080000
136546865 OLOGY G Nov. 22, 2021, 6:59 p.m. OK PyPy 3 TESTS 21 779 48332800
136543659 OLOGY G Nov. 22, 2021, 6:06 p.m. OK PyPy 3-64 TESTS 21 390 62361600
136549456 conqueror_of_tourist G Nov. 22, 2021, 7:53 p.m. OK PyPy 3-64 TESTS 21 732 68198400
136549266 sansen G Nov. 22, 2021, 7:48 p.m. OK Rust TESTS 21 77 27340800

remove filters

Back to search problems