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 |
---|---|---|---|---|---|---|
1995 | Codeforces Round 961 (Div. 2) | FINISHED | False | 7200 | 10077899 | July 23, 2024, 2:35 p.m. |
Solved$ |
Index |
Name |
Type |
Tags |
Community Tag |
Rating |
---|---|---|---|---|---|---|
( 8556 ) | C | Squaring | PROGRAMMING | brute force constructive algorithms data structures greedy implementation math number theory |
B"ikrpprpp found an array a consisting of integers. He likes justice, so he wants to make a fair -- that is, make it non-decreasing. To do that, he can perform an act of justice on an index 1 <= i <= n of the array, which will replace a_i with a_i ^ 2 (the element at position i with its square). For example, if a = [2,4,3,3,5,3] and ikrpprpp chooses to perform an act of justice on i = 4 , a becomes [2,4,3,9,5,3] . What is the minimum number of acts of justice needed to make the array non-decreasing? First line contains an integer t ( 1 <= t <= 1000 ) -- the number of test cases. It is followed by the description of test cases. For each test case, the first line contains an integer n -- size of the array a . The second line contains n ( 1 <= n <= 2 cdot 10 ^5 ) integers a_1, a_2, ldots, a_n ( 1 <= a_i <= 10 ^ 6 ). The sum of n over all test cases does not exceed 2 cdot {10}^5 . For each testcase, print an integer -- minimum number of acts of justice required to make the array a non-decreasing. If it is impossible to do that, print -1 . In the first test case, there's no need to perform acts of justice. The array is fair on its own! In the third test case, it can be proven that the array cannot become non-decreasing. In the fifth test case, ikrpprppp can perform an act of justice on index 3, then an act of justice on index 2, and finally yet another act of justice on index 3. After that, a will become [4, 9, 16] . "... |
Video Tutorial |
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
---|---|---|---|---|---|---|---|---|---|---|---|
272256246 | Neel17 | C | July 24, 2024, 5:54 a.m. | OK | C++14 (GCC 6-32) | TESTS | 23 | 77 | 0 | ||
272225290 | yzy001633 | C | July 23, 2024, 11:58 p.m. | OK | C++14 (GCC 6-32) | TESTS | 23 | 78 | 3174400 | ||
272250704 | hou521 | C | July 24, 2024, 4:58 a.m. | OK | C++14 (GCC 6-32) | TESTS | 23 | 93 | 0 | ||
272228719 | sz_jinzikai01 | C | July 24, 2024, 12:59 a.m. | OK | C++14 (GCC 6-32) | TESTS | 23 | 93 | 0 | ||
272214804 | start_end | C | July 23, 2024, 8:28 p.m. | OK | C++14 (GCC 6-32) | TESTS | 22 | 93 | 0 | ||
272213749 | _toothless | C | July 23, 2024, 8:15 p.m. | OK | C++14 (GCC 6-32) | TESTS | 22 | 93 | 0 | ||
272208272 | zhuge0 | C | July 23, 2024, 7:12 p.m. | OK | C++14 (GCC 6-32) | TESTS | 22 | 93 | 0 | ||
272176428 | Guslix | C | July 23, 2024, 5:24 p.m. | OK | C++14 (GCC 6-32) | TESTS | 21 | 93 | 0 | ||
272232711 | 729hao | C | July 24, 2024, 1:50 a.m. | OK | C++14 (GCC 6-32) | TESTS | 23 | 93 | 819200 | ||
272255475 | darkshadow2 | C | July 24, 2024, 5:47 a.m. | OK | C++14 (GCC 6-32) | TESTS | 23 | 93 | 1638400 | ||
272196199 | soup | C | July 23, 2024, 5:37 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 77 | 0 | ||
272174090 | Tor_250 | C | July 23, 2024, 5:12 p.m. | OK | C++17 (GCC 7-32) | TESTS | 21 | 77 | 0 | ||
272245561 | Jiangnan111 | C | July 24, 2024, 4:01 a.m. | OK | C++17 (GCC 7-32) | TESTS | 23 | 77 | 1638400 | ||
272242722 | whaoe | C | July 24, 2024, 3:30 a.m. | OK | C++17 (GCC 7-32) | TESTS | 23 | 77 | 3174400 | ||
272256966 | kundan21 | C | July 24, 2024, 6:01 a.m. | OK | C++17 (GCC 7-32) | TESTS | 23 | 78 | 0 | ||
272256108 | Mark2012 | C | July 24, 2024, 5:52 a.m. | OK | C++17 (GCC 7-32) | TESTS | 23 | 78 | 0 | ||
272249420 | PerfectLife | C | July 24, 2024, 4:45 a.m. | OK | C++17 (GCC 7-32) | TESTS | 23 | 78 | 0 | ||
272246943 | yyc4591 | C | July 24, 2024, 4:17 a.m. | OK | C++17 (GCC 7-32) | TESTS | 23 | 78 | 0 | ||
272231061 | GULUJUN | C | July 24, 2024, 1:31 a.m. | OK | C++17 (GCC 7-32) | TESTS | 23 | 78 | 0 | ||
272223084 | Aamkinova757575 | C | July 23, 2024, 11 p.m. | OK | C++17 (GCC 7-32) | TESTS | 23 | 78 | 0 | ||
272254047 | 2410017640 | C | July 24, 2024, 5:32 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 62 | 0 | ||
272253193 | soumya_1 | C | July 24, 2024, 5:23 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 62 | 0 | ||
272239073 | watcherrr | C | July 24, 2024, 2:56 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 62 | 0 | ||
272223977 | vishnu_1264 | C | July 23, 2024, 11:23 p.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 62 | 0 | ||
272235411 | qcode_aya | C | July 24, 2024, 2:21 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 62 | 4812800 | ||
272255440 | CEKPET | C | July 24, 2024, 5:46 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 77 | 0 | ||
272253910 | youngr | C | July 24, 2024, 5:31 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 77 | 0 | ||
272252492 | Arrebol6 | C | July 24, 2024, 5:16 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 77 | 0 | ||
272251715 | PoetryFactory | C | July 24, 2024, 5:09 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 77 | 0 | ||
272251278 | GunSJ | C | July 24, 2024, 5:04 a.m. | OK | C++20 (GCC 13-64) | TESTS | 23 | 77 | 0 | ||
272202458 | NenadDapic | C | July 23, 2024, 6:20 p.m. | OK | FPC | TESTS | 22 | 77 | 0 | ||
272199288 | NenadDapic | C | July 23, 2024, 5:57 p.m. | OK | FPC | TESTS | 22 | 109 | 1638400 | ||
272202031 | ruban | C | July 23, 2024, 6:17 p.m. | OK | FPC | TESTS | 22 | 124 | 156774400 | ||
272208282 | SanjivDinakar | C | July 23, 2024, 7:13 p.m. | OK | GNU C11 | TESTS | 22 | 92 | 102400 | ||
272230613 | Orange905 | C | July 24, 2024, 1:25 a.m. | OK | Java 21 | TESTS | 23 | 264 | 1024000 | ||
272213274 | RockingMat | C | July 23, 2024, 8:09 p.m. | OK | Java 21 | TESTS | 22 | 280 | 1536000 | ||
272195753 | lyongwolf | C | July 23, 2024, 5:35 p.m. | OK | Java 21 | TESTS | 21 | 296 | 716800 | ||
272199661 | codeWithDarshan | C | July 23, 2024, 6 p.m. | OK | Java 21 | TESTS | 22 | 296 | 819200 | ||
272197765 | sahasrad | C | July 23, 2024, 5:48 p.m. | OK | Java 21 | TESTS | 21 | 327 | 614400 | ||
272176305 | InfinityX | C | July 23, 2024, 5:23 p.m. | OK | Java 21 | TESTS | 21 | 343 | 614400 | ||
272174455 | dzhi | C | July 23, 2024, 5:14 p.m. | OK | Java 21 | TESTS | 21 | 343 | 716800 | ||
272211642 | man-ray | C | July 23, 2024, 7:49 p.m. | OK | Java 21 | TESTS | 22 | 343 | 10649600 | ||
272204257 | daksh_02 | C | July 23, 2024, 6:34 p.m. | OK | Java 21 | TESTS | 22 | 359 | 11776000 | ||
272204151 | PlayDate | C | July 23, 2024, 6:33 p.m. | OK | Java 21 | TESTS | 22 | 592 | 1331200 | ||
272209485 | kasiru_69 | C | July 23, 2024, 7:25 p.m. | OK | Java 8 | TESTS | 22 | 218 | 3379200 | ||
272207820 | RebibeMeJett | C | July 23, 2024, 7:08 p.m. | OK | Java 8 | TESTS | 22 | 218 | 3481600 | ||
272211740 | white___devil | C | July 23, 2024, 7:50 p.m. | OK | Java 8 | TESTS | 22 | 374 | 0 | ||
272206202 | dauletomarov1130 | C | July 23, 2024, 6:52 p.m. | OK | Java 8 | TESTS | 22 | 405 | 0 | ||
272205961 | dauletomarov1130 | C | July 23, 2024, 6:50 p.m. | OK | Java 8 | TESTS | 22 | 406 | 0 | ||
272246385 | lh_code | C | July 24, 2024, 4:10 a.m. | OK | PyPy 3 | TESTS | 23 | 281 | 16179200 | ||
272254697 | Traverser_Steal69 | C | July 24, 2024, 5:39 a.m. | OK | PyPy 3 | TESTS | 23 | 390 | 13721600 | ||
272176220 | Ahmed_Turkman | C | July 23, 2024, 5:22 p.m. | OK | PyPy 3 | TESTS | 21 | 390 | 15667200 | ||
272213779 | Om_Singh_ | C | July 23, 2024, 8:15 p.m. | OK | PyPy 3-64 | TESTS | 22 | 124 | 26112000 | ||
272214219 | Om_Singh_ | C | July 23, 2024, 8:21 p.m. | OK | PyPy 3-64 | TESTS | 22 | 124 | 26214400 | ||
272208207 | eyobworku | C | July 23, 2024, 7:12 p.m. | OK | PyPy 3-64 | TESTS | 22 | 124 | 27238400 | ||
272214655 | tyler23492130 | C | July 23, 2024, 8:27 p.m. | OK | PyPy 3-64 | TESTS | 22 | 139 | 27136000 | ||
272196045 | m4nd9 | C | July 23, 2024, 5:36 p.m. | OK | PyPy 3-64 | TESTS | 21 | 140 | 25804800 | ||
272253784 | gardengnome | C | July 24, 2024, 5:29 a.m. | OK | PyPy 3-64 | TESTS | 23 | 140 | 26214400 | ||
272213735 | Om_Singh_ | C | July 23, 2024, 8:14 p.m. | OK | PyPy 3-64 | TESTS | 22 | 140 | 26214400 | ||
272240150 | Bigarade | C | July 24, 2024, 3:07 a.m. | OK | PyPy 3-64 | TESTS | 23 | 140 | 26419200 | ||
272205073 | Abdulxay4545 | C | July 23, 2024, 6:41 p.m. | OK | PyPy 3-64 | TESTS | 22 | 155 | 26214400 | ||
272251633 | NickFury12 | C | July 24, 2024, 5:08 a.m. | OK | PyPy 3-64 | TESTS | 23 | 155 | 27238400 | ||
272213801 | Om_Singh_ | C | July 23, 2024, 8:15 p.m. | OK | Python 3 | TESTS | 22 | 171 | 26624000 | ||
272245680 | Minh20112009 dona10khoa_nhd | C | July 24, 2024, 4:03 a.m. | OK | Python 3 | TESTS | 23 | 202 | 24576000 | ||
272176325 | WTC_W | C | July 23, 2024, 5:23 p.m. | OK | Python 3 | TESTS | 21 | 249 | 26726400 | ||
272238451 | _regular_show | C | July 24, 2024, 2:51 a.m. | OK | Python 3 | TESTS | 23 | 265 | 26624000 | ||
272174489 | DeanMMenezes | C | July 23, 2024, 5:14 p.m. | OK | Python 3 | TESTS | 21 | 327 | 26112000 | ||
272209693 | Redpanda_x | C | July 23, 2024, 7:27 p.m. | OK | Python 3 | TESTS | 22 | 327 | 26624000 | ||
272199613 | renatxat | C | July 23, 2024, 6 p.m. | OK | Python 3 | TESTS | 22 | 343 | 26726400 | ||
272199044 | octopoda | C | July 23, 2024, 5:56 p.m. | OK | Python 3 | TESTS | 22 | 530 | 33177600 | ||
272220942 | DeanMMenezes | C | July 23, 2024, 10:09 p.m. | OK | Rust 2021 | TESTS | 23 | 62 | 2560000 | ||
272176028 | jenya705 | C | July 23, 2024, 5:21 p.m. | OK | Rust 2021 | TESTS | 21 | 62 | 4198400 | ||
272255478 | Dynamic_Pigeon | C | July 24, 2024, 5:47 a.m. | OK | Rust 2021 | TESTS | 23 | 78 | 11366400 |
Back to search problems