Codeforces Round 1047 (Div. 3)

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
2137 Codeforces Round 1047 (Div. 3) FINISHED False 8100 19149923 Sept. 7, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 4025 ) F Prefix Maximum Invariance PROGRAMMING binary search data structures sortings

Given two arrays (x) and (y) both of size (m), let (z) be another array of size (m) such that the prefix maximum at each position of (z) is the same as the prefix maximum at each position of (x). Formally, (\operatorname{max}(x_1,x_2,\ldots,x_i)=\operatorname{max}(z_1,z_2,\ldots,z_i)) should hold for all (1 \leq i \leq m). Define (f(x,y)) to be the maximum number of positions where (z_i=y_i) over all possible arrays (z). You are given two sequences of integers (a) and (b), both of size (n). Please find the value of (\sum_{l=1}^n\sum_{r=l}^n f(a_l,a_{l+1},\ldots,a_r, b_l,b_{l+1},\ldots,b_r)). 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 test case contains an integer (n) ((1 \leq n \leq 2\cdot 10^5)). The second line contains (n) integers (a_1,a_2,\ldots,a_n) ((1 \leq a_i \leq 2\cdot n)). The third line contains (n) integers (b_1,b_2,\ldots,b_n) ((1 \leq b_i \leq 2\cdot n)). It is guaranteed that the sum of (n) over all test cases does not exceed (2\cdot 10^5). For each test case, output the sum of (f(a_l,a_{l+1},\ldots,a_r, b_l,b_{l+1},\ldots,b_r)) over all pairs of ((l,r)). In the first test case, the answer is the sum of the following: (f(5,4)=0), using (z=5). (f(3,2)=0), using (z=3). (f(1,1)=1), using (z=1). (f(5,3,4,2)=1), using (z=5,2). (f(3,1, 2,1)=1), using (z=3,1). (f(5,3,1,4,2,1)=2), using (z=5,2,1).

Tutorials

Codeforces Round 1047 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
337467007 TheSupremacy55 F Sept. 7, 2025, 7:36 p.m. OK C++17 (GCC 7-32) TESTS 10 108 102400
337475431 lordlorinc F Sept. 7, 2025, 9:40 p.m. OK C++17 (GCC 7-32) TESTS 10 109 0
337459363 haha1324 F Sept. 7, 2025, 6:16 p.m. OK C++17 (GCC 7-32) TESTS 10 109 0
337477438 VaHiX F Sept. 7, 2025, 10:24 p.m. OK C++17 (GCC 7-32) TESTS 10 109 3276800
337466923 TheSupremacy55 F Sept. 7, 2025, 7:35 p.m. OK C++17 (GCC 7-32) TESTS 10 109 3276800
337464243 -Guts F Sept. 7, 2025, 7:04 p.m. OK C++17 (GCC 7-32) TESTS 10 109 3276800
337454363 Narendra.Singh F Sept. 7, 2025, 5:38 p.m. OK C++17 (GCC 7-32) TESTS 10 109 3276800
337495557 TT87cf F Sept. 8, 2025, 4:55 a.m. OK C++17 (GCC 7-32) TESTS 10 124 0
337474374 cyu17 F Sept. 7, 2025, 9:18 p.m. OK C++17 (GCC 7-32) TESTS 10 124 0
337469697 itsrohit F Sept. 7, 2025, 8:05 p.m. OK C++17 (GCC 7-32) TESTS 10 124 0
337498026 LuOH3_ F Sept. 8, 2025, 5:29 a.m. OK C++20 (GCC 13-64) TESTS 10 93 102400
337484498 LiKeROSE F Sept. 8, 2025, 1:39 a.m. OK C++20 (GCC 13-64) TESTS 10 93 819200
337450279 ToT F Sept. 7, 2025, 5:12 p.m. OK C++20 (GCC 13-64) TESTS 10 93 5734400
337487626 arthurxu17 F Sept. 8, 2025, 2:43 a.m. OK C++20 (GCC 13-64) TESTS 10 108 0
337470607 CutSandstone F Sept. 7, 2025, 8:17 p.m. OK C++20 (GCC 13-64) TESTS 10 108 0
337460657 Ayham_Dabah F Sept. 7, 2025, 6:27 p.m. OK C++20 (GCC 13-64) TESTS 10 108 0
337459076 mhmusanna F Sept. 7, 2025, 6:14 p.m. OK C++20 (GCC 13-64) TESTS 10 108 0
337458177 cse220001042 F Sept. 7, 2025, 6:06 p.m. OK C++20 (GCC 13-64) TESTS 10 108 102400
337466006 KoKoDuDu F Sept. 7, 2025, 7:24 p.m. OK C++20 (GCC 13-64) TESTS 10 108 921600
337476902 OmarAli. F Sept. 7, 2025, 10:10 p.m. OK C++20 (GCC 13-64) TESTS 10 109 0
337458320 424479543 F Sept. 7, 2025, 6:07 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 62 102400
337460164 424479543 F Sept. 7, 2025, 6:23 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 77 3072000
337459895 424479543 F Sept. 7, 2025, 6:21 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 77 3072000
337495280 rumike F Sept. 8, 2025, 4:51 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
337493150 SapeginIgor F Sept. 8, 2025, 4:14 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
337482970 Hoang_Thien_De F Sept. 8, 2025, 1:01 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 0
337481696 jackylova_fan_fan_fan F Sept. 8, 2025, 12:30 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 819200
337488699 Alice486 F Sept. 8, 2025, 2:59 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 1024000
337488270 retah F Sept. 8, 2025, 2:53 a.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 2457600
337463302 who1sShakin F Sept. 7, 2025, 6:53 p.m. OK C++23 (GCC 14-64, msys2) TESTS 10 93 3174400
337476378 BOB_005 F Sept. 7, 2025, 9:57 p.m. OK Java 21 TESTS 10 358 6348800
337450318 wenbozh F Sept. 7, 2025, 5:12 p.m. OK Java 21 TESTS 10 374 614400
337452160 sahasrad F Sept. 7, 2025, 5:23 p.m. OK Java 21 TESTS 10 390 1536000
337449517 wddd F Sept. 7, 2025, 5:08 p.m. OK Java 21 TESTS 10 406 7680000
337448113 chiragsingh876 F Sept. 7, 2025, 5:01 p.m. OK Java 21 TESTS 10 530 26931200
337450390 nabina1395 F Sept. 7, 2025, 5:13 p.m. OK Java 21 TESTS 10 593 6348800
337465021 Bogys F Sept. 7, 2025, 7:12 p.m. OK Java 21 TESTS 10 1327 26419200
337447450 divya8080 F Sept. 7, 2025, 4:58 p.m. OK Java 8 TESTS 10 280 10342400
337465177 kasiru_69 F Sept. 7, 2025, 7:14 p.m. OK Java 8 TESTS 10 296 23961600
337451733 aaraverma7 F Sept. 7, 2025, 5:21 p.m. OK Java 8 TESTS 10 390 34611200
337448241 Vinayak1031 F Sept. 7, 2025, 5:01 p.m. OK Java 8 TESTS 10 437 7577600
337446153 Eslam_Ahmed F Sept. 7, 2025, 4:52 p.m. OK Java 8 TESTS 10 499 55091200
337447926 chinesedfan F Sept. 7, 2025, 5 p.m. OK Node.js TESTS 10 577 74547200
337465800 Om_Singh_ F Sept. 7, 2025, 7:21 p.m. OK PyPy 3-64 TESTS 10 218 31129600
337449401 x3mka F Sept. 7, 2025, 5:07 p.m. OK PyPy 3-64 TESTS 10 218 32768000
337488486 jvatsal0709 F Sept. 8, 2025, 2:56 a.m. OK PyPy 3-64 TESTS 10 233 33280000
337473263 sujal.gamer18 F Sept. 7, 2025, 8:58 p.m. OK PyPy 3-64 TESTS 10 234 37990400
337450198 braveblc F Sept. 7, 2025, 5:11 p.m. OK PyPy 3-64 TESTS 10 249 26828800
337477042 hugoback01 F Sept. 7, 2025, 10:13 p.m. OK PyPy 3-64 TESTS 10 249 28467200
337490070 Little_Sheep_Yawn F Sept. 8, 2025, 3:20 a.m. OK PyPy 3-64 TESTS 10 249 31846400
337462746 FikreyohanesAbera F Sept. 7, 2025, 6:48 p.m. OK PyPy 3-64 TESTS 10 265 34508800
337488228 xyyyyyyyyyyy F Sept. 8, 2025, 2:52 a.m. OK PyPy 3-64 TESTS 10 265 34918400
337485565 aviral311 F Sept. 8, 2025, 2:03 a.m. OK PyPy 3-64 TESTS 10 281 27443200
337494437 HyperBoolean F Sept. 8, 2025, 4:38 a.m. OK Python 3 TESTS 10 765 30515200

remove filters

Back to search problems