Codeforces Round 1095 (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
2226 Codeforces Round 1095 (Div. 2) FINISHED False 8100 1178664 April 28, 2026, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 10577 ) B Everything Everywhere PROGRAMMING greedy math number theory

An array is called good if the difference between the maximum value and the minimum value in the array is equal to the greatest common divisor (GCD) of all the elements in the array. Note that an empty array is considered to be not good. More formally, an array (a_1, a_2, \ldots, a_m) is good if and only if () \max(a_1, a_2, \ldots, a_m) - \min(a_1, a_2, \ldots, a_m) = \gcd(a_1, a_2, \ldots, a_m).() You are given a permutation(^{\text{∗}}) (p) of length (n). Determine the number of good subarrays(^{\text{†}}) in the given permutation. (^{\text{∗}})A permutation of length (m) is an array consisting of (m) distinct integers from (1) to (m) in arbitrary order. For example, (2,3,1,5,4) is a permutation, but (1,2,2) is not a permutation ((2) appears twice in the array), and (1,3,4) is also not a permutation ((m=3) but there is (4) in the array). (^{\text{†}})An array (b) is a subarray of an array (a) if (b) can be obtained from (a) by the deletion of several (possibly, zero or all) elements from the beginning and several (possibly, zero or all) elements from the end. In particular, an array is a subarray of itself. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 10^4)). The description of the test cases follows. The first line of each testcase contains a single integer (n) ((2 \le n \le 2 \cdot 10^5)) — the length of the permutation (p). The second line of each testcase contains (n) integers (p_1, p_2, \ldots, p_n) ((1 \le p_i \le n)) — the permutation (p). It is guaranteed that (p) is a permutation. It is guaranteed that the sum of (n) over all the test cases does not exceed (2 \cdot 10^5). For each testcase, print a single integer — the number of good subarrays in the given permutation. For the first testcase, only one subarray is good, which is $$$1, 2$

Tutorials

Codeforces Round 1095 (Div. 2) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
372856732 caffeine2ac B April 28, 2026, 3:54 p.m. OK C# 13 TESTS 10 109 13619200
372862251 Ray950104 B April 28, 2026, 4:12 p.m. OK C++17 (GCC 7-32) TESTS 10 46 102400
372898090 _Mohmed_Khaled_Gado_255 B April 28, 2026, 11:45 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372894597 Farrukh_ B April 28, 2026, 9:43 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372881244 samyak272005 B April 28, 2026, 6:21 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372879075 farhan3011 B April 28, 2026, 6:01 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372876047 Husein B April 28, 2026, 5:32 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372870840 mrtrojzl B April 28, 2026, 4:43 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372869816 _Jeweler B April 28, 2026, 4:39 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372866654 AmanKakadiya301 B April 28, 2026, 4:28 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372865402 YQ11 B April 28, 2026, 4:23 p.m. OK C++17 (GCC 7-32) TESTS 10 62 0
372912791 KafkaBug B April 29, 2026, 5:58 a.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372911223 AbdalAzeem22 B April 29, 2026, 5:34 a.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372904679 alamgir65 B April 29, 2026, 3:15 a.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372903638 gwd B April 29, 2026, 2:49 a.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372902822 kaushall_p B April 29, 2026, 2:28 a.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372894794 GutturalCord31 B April 28, 2026, 9:49 p.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372889993 muhammad_ali_7 B April 28, 2026, 8:07 p.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372887847 bitwiseTanuj B April 28, 2026, 7:36 p.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372885623 Dorra1234 B April 28, 2026, 7:10 p.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372882463 Abdulla_Ahmed_ B April 28, 2026, 6:34 p.m. OK C++20 (GCC 13-64) TESTS 10 62 0
372909331 sarvan.dp.grandmaster B April 29, 2026, 5:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
372888232 GP117 B April 28, 2026, 7:40 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
372878473 Tomate B April 28, 2026, 5:56 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
372857893 potapenkofil B April 28, 2026, 3:58 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 0
372856778 Iagoap B April 28, 2026, 3:54 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 102400
372905968 binglengmo B April 29, 2026, 3:46 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 307200
372906827 Smallplane B April 29, 2026, 4:06 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 46 2150400
372912367 s1mply B April 29, 2026, 5:52 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 62 0
372911934 2k11dentusapa B April 29, 2026, 5:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 62 0
372911508 LYC_666 B April 29, 2026, 5:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 62 0
372871709 Vaanya_Gupta B April 28, 2026, 4:47 p.m. OK GNU C11 TESTS 10 46 0
372864838 dhiraj_pgcat B April 28, 2026, 4:21 p.m. OK GNU C11 TESTS 10 62 0
372859706 Enkebno B April 28, 2026, 4:04 p.m. OK GNU C11 TESTS 10 62 716800
372864258 S-D-07 B April 28, 2026, 4:19 p.m. OK GNU C11 TESTS 10 78 716800
372885350 Banwait B April 28, 2026, 7:07 p.m. OK GNU C11 TESTS 10 78 819200
372855353 DaeSu B April 28, 2026, 3:50 p.m. OK GNU C11 TESTS 10 78 819200
372863372 finfin41 B April 28, 2026, 4:16 p.m. OK GNU C11 TESTS 10 78 1126400
372867191 ChrisCode_forces B April 28, 2026, 4:29 p.m. OK GNU C11 TESTS 10 93 819200
372868868 jan1337 B April 28, 2026, 4:36 p.m. OK Go TESTS 10 62 7577600
372870803 Meenachinmay B April 28, 2026, 4:43 p.m. OK Go TESTS 10 125 2867200
372903646 Devstudent01 B April 29, 2026, 2:49 a.m. OK Java 21 TESTS 10 203 307200
372856958 prachiiiiii B April 28, 2026, 3:55 p.m. OK Java 21 TESTS 10 203 18841600
372869537 kartikjaju5 B April 28, 2026, 4:38 p.m. OK Java 21 TESTS 10 218 0
372855586 mohith.nakka1976 B April 28, 2026, 3:50 p.m. OK Java 21 TESTS 10 218 409600
372902794 pushkar.lonkar21 B April 29, 2026, 2:27 a.m. OK Java 21 TESTS 10 234 1433600
372887145 hg_2005 B April 28, 2026, 7:28 p.m. OK Java 21 TESTS 10 250 204800
372866191 yadavrajakran854 B April 28, 2026, 4:26 p.m. OK Java 21 TESTS 10 250 307200
372865957 tyagidhruv001 B April 28, 2026, 4:25 p.m. OK Java 21 TESTS 10 250 512000
372907925 codeTitanX B April 29, 2026, 4:33 a.m. OK Java 21 TESTS 10 250 1433600
372866973 mohd_faisal9372 B April 28, 2026, 4:29 p.m. OK Java 21 TESTS 10 250 1638400
372859389 vimal_VJ B April 28, 2026, 4:03 p.m. OK Java 8 TESTS 10 109 0
372868542 maniteja517 B April 28, 2026, 4:35 p.m. OK Java 8 TESTS 10 140 409600
372858250 em3987 B April 28, 2026, 3:59 p.m. OK Java 8 TESTS 10 156 2662400
372913200 Pranav_45 B April 29, 2026, 6:04 a.m. OK Java 8 TESTS 10 156 39014400
372900066 public-static-void-main B April 29, 2026, 1:04 a.m. OK Java 8 TESTS 10 171 31744000
372875117 Journey_21 B April 28, 2026, 5:25 p.m. OK Java 8 TESTS 10 375 0
372867107 0xdaksh.12 B April 28, 2026, 4:29 p.m. OK Java 8 TESTS 10 375 0
372858544 manavajk26 B April 28, 2026, 4 p.m. OK Java 8 TESTS 10 375 0
372861161 trylearnforever B April 28, 2026, 4:08 p.m. OK Java 8 TESTS 10 390 0
372861019 M_oksh07 B April 28, 2026, 4:08 p.m. OK Java 8 TESTS 10 390 0
372862714 modhshubhr B April 28, 2026, 4:14 p.m. OK Kotlin 2.2 TESTS 10 250 24678400
372864169 bitplease_ B April 28, 2026, 4:19 p.m. OK Node.js TESTS 10 140 20070400
372900243 chmpro B April 29, 2026, 1:10 a.m. OK Perl TESTS 10 218 18329600
372856714 Cygnus_M B April 28, 2026, 3:54 p.m. OK PyPy 2 TESTS 10 156 13721600
372892527 jsaddict044 B April 28, 2026, 8:51 p.m. OK PyPy 3 TESTS 10 203 14233600
372861135 pyyyyp B April 28, 2026, 4:08 p.m. OK PyPy 3 TESTS 10 218 13004800
372871466 vishanthrajasekar B April 28, 2026, 4:46 p.m. OK PyPy 3 TESTS 10 218 14745600
372862823 Gaddour_Yessine B April 28, 2026, 4:14 p.m. OK PyPy 3 TESTS 10 281 12697600
372860225 Shotgun_pink B April 28, 2026, 4:06 p.m. OK PyPy 3 TESTS 10 328 12800000
372909633 Nont1000 B April 29, 2026, 5:08 a.m. OK PyPy 3-64 TESTS 10 109 16486400
372885547 Lakshay_Arya B April 28, 2026, 7:09 p.m. OK PyPy 3-64 TESTS 10 109 19763200
372869102 hirose B April 28, 2026, 4:37 p.m. OK PyPy 3-64 TESTS 10 109 21196800
372857989 SandeepMoharana B April 28, 2026, 3:58 p.m. OK PyPy 3-64 TESTS 10 125 19558400
372906218 v-cash B April 29, 2026, 3:52 a.m. OK PyPy 3-64 TESTS 10 125 19660800
372909097 aloxoja_0703 B April 29, 2026, 4:57 a.m. OK PyPy 3-64 TESTS 10 125 19763200
372900677 Ahmed_JF B April 29, 2026, 1:23 a.m. OK PyPy 3-64 TESTS 10 125 20582400
372899267 VGCos B April 29, 2026, 12:34 a.m. OK PyPy 3-64 TESTS 10 125 20582400
372865514 ep268gza B April 28, 2026, 4:23 p.m. OK PyPy 3-64 TESTS 10 125 20582400
372885014 Tresm0k B April 28, 2026, 7:04 p.m. OK PyPy 3-64 TESTS 10 125 20684800
372875624 eugalt B April 28, 2026, 5:29 p.m. OK Python 3 TESTS 10 109 23859200
372866493 Muqeem B April 28, 2026, 4:27 p.m. OK Python 3 TESTS 10 125 14540800
372900102 chmpro B April 29, 2026, 1:05 a.m. OK Python 3 TESTS 10 125 14950400
372875668 eteresh B April 28, 2026, 5:29 p.m. OK Python 3 TESTS 10 125 22835200
372886900 Bhavishya_Jhamb B April 28, 2026, 7:25 p.m. OK Python 3 TESTS 10 125 23449600
372870434 nurulaziz B April 28, 2026, 4:42 p.m. OK Python 3 TESTS 10 125 23552000
372864881 Prestige B April 28, 2026, 4:21 p.m. OK Python 3 TESTS 10 125 24576000
372867822 Birchove B April 28, 2026, 4:32 p.m. OK Python 3 TESTS 10 140 22732800
372865582 BenignSaw B April 28, 2026, 4:24 p.m. OK Python 3 TESTS 10 140 23449600
372870930 nuriyevisa10 B April 28, 2026, 4:44 p.m. OK Python 3 TESTS 10 140 23756800
372908983 Tantellam B April 29, 2026, 4:54 a.m. OK Rust 2024 TESTS 10 46 12492800
372862222 trycatchcry B April 28, 2026, 4:12 p.m. OK Rust 2024 TESTS 10 46 12492800
372896752 sirreidlos B April 28, 2026, 10:53 p.m. OK Rust 2024 TESTS 10 78 11776000
372855206 123gjweq2 B April 28, 2026, 3:49 p.m. OK Rust 2024 TESTS 10 234 30617600

remove filters

Back to search problems