Codeforces Round 1029 (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
2117 Codeforces Round 1029 (Div. 3) FINISHED False 8100 27012323 June 8, 2025, 2:35 p.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 11785 ) E Lost Soul PROGRAMMING greedy

You are given two integer arrays (a) and (b), each of length (n). You may perform the following operation any number of times: Choose an index (i) ((1 \le i \le n - 1)), and set (a_i := b_{i + 1}), or set (b_i := a_{i + 1}). Before performing any operations, you are allowed to choose an index (i) ((1 \le i \le n)) and remove both (a_i) and (b_i) from the arrays. This removal can be done at most once . Let the number of matches between two arrays (c) and (d) of length (m) be the number of positions (j) ((1 \le j \le m)) such that (c_j = d_j). Your task is to compute the maximum number of matches you can achieve. The first line of the input contains an integer (t) ((1 \le t \le 10^4)) — the number of test cases. The description of each test case follows. The first line contains an integer (n) ((2 \le n \le 2 \cdot 10^5)) — the length of (a) and (b). The second line contains (n) integers (a_1, a_2, \dots, a_n) ((1 \le a_i \le n)) — the elements of (a). The third line contains (n) integers (b_1, b_2, \dots, b_n) ((1 \le b_i \le n)) — the elements of (b). It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, print a single integer — the answer for the test case. In the first test case, we can do the following: We will choose not to remove any index. Choose index (3), and set (a_3 := b_4). The arrays become: (a = 1, 3, 2, 4), (b = 4, 3, 2, 2). Choose index (1), and set (a_1 := b_2). The arrays become: (a = 3, 3, 2, 4), (b = 4, 3, 2, 2). Choose index (1), and set (b_1 := a_2). The arrays become: (a = 3, 3, 2, 4), (b = 3, 3, 2, 2). Notice that you can perform (a_i := b_{i + 1}) and (b_i := a_{i + 1}) on the same index (i). The number of matches is (3). It can be shown that this is the maximum answer we can

Tutorials

Codeforces Round 1029 (Div. 3) Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
323713442 og.kostya E June 10, 2025, 5:12 a.m. OK C# 13 TESTS 20 139 2457600
323698719 Segment.Tree E June 10, 2025, 1:19 a.m. OK C++17 (GCC 7-32) TESTS 20 109 0
323673311 maksatchs E June 9, 2025, 5:45 p.m. OK C++17 (GCC 7-32) TESTS 19 109 102400
323670776 Afjal_Sayed E June 9, 2025, 5:23 p.m. OK C++17 (GCC 7-32) TESTS 19 109 102400
323637603 Agnight866 E June 9, 2025, 1:08 p.m. OK C++17 (GCC 7-32) TESTS 19 109 102400
323627442 SeptFlame E June 9, 2025, 11:54 a.m. OK C++17 (GCC 7-32) TESTS 19 109 102400
323626507 Polinka27 E June 9, 2025, 11:47 a.m. OK C++17 (GCC 7-32) TESTS 19 109 102400
323582968 Utkarsh_09 E June 9, 2025, 5:48 a.m. OK C++17 (GCC 7-32) TESTS 19 109 1126400
323701971 Njasoo E June 10, 2025, 2:24 a.m. OK C++17 (GCC 7-32) TESTS 20 109 2457600
323655114 zwx1224 E June 9, 2025, 3:19 p.m. OK C++17 (GCC 7-32) TESTS 19 109 3276800
323689923 poz3 E June 9, 2025, 9:01 p.m. OK C++17 (GCC 7-32) TESTS 20 109 6041600
323705975 Icy_ E June 10, 2025, 3:32 a.m. OK C++20 (GCC 13-64) TESTS 20 93 102400
323698766 sailealt31 E June 10, 2025, 1:20 a.m. OK C++20 (GCC 13-64) TESTS 20 93 102400
323695215 Soria. E June 9, 2025, 11:25 p.m. OK C++20 (GCC 13-64) TESTS 20 93 102400
323665601 Aya_k E June 9, 2025, 4:42 p.m. OK C++20 (GCC 13-64) TESTS 19 93 102400
323664961 Drink_to_forget E June 9, 2025, 4:38 p.m. OK C++20 (GCC 13-64) TESTS 19 93 102400
323625998 Sachchit E June 9, 2025, 11:43 a.m. OK C++20 (GCC 13-64) TESTS 19 93 102400
323631144 xiaci E June 9, 2025, 12:21 p.m. OK C++20 (GCC 13-64) TESTS 19 108 307200
323652268 Dheeraj1706 E June 9, 2025, 2:55 p.m. OK C++20 (GCC 13-64) TESTS 19 108 2764800
323605793 Koncloud E June 9, 2025, 9:14 a.m. OK C++20 (GCC 13-64) TESTS 19 108 3481600
323706075 ks07onmc117 E June 10, 2025, 3:34 a.m. OK C++20 (GCC 13-64) TESTS 20 109 0
323713328 sickboydroid E June 10, 2025, 5:11 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 93 102400
323706346 _clint E June 10, 2025, 3:38 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 93 102400
323657262 fafuwyx666 E June 9, 2025, 3:36 p.m. OK C++23 (GCC 14-64, msys2) TESTS 19 93 102400
323651142 Ramzi9 E June 9, 2025, 2:47 p.m. OK C++23 (GCC 14-64, msys2) TESTS 19 93 102400
323703735 FrederickG_ E June 10, 2025, 2:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 93 1331200
323661638 Mohamedicpc E June 9, 2025, 4:12 p.m. OK C++23 (GCC 14-64, msys2) TESTS 19 108 0
323661199 xiaohuang25 E June 9, 2025, 4:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 19 108 0
323705265 Owstin E June 10, 2025, 3:21 a.m. OK C++23 (GCC 14-64, msys2) TESTS 20 108 102400
323676048 isee E June 9, 2025, 6:08 p.m. OK C++23 (GCC 14-64, msys2) TESTS 20 108 102400
323660630 Anurag2004 E June 9, 2025, 4:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 19 108 102400
323604226 VaishCodes E June 9, 2025, 9:04 a.m. OK GNU C11 TESTS 19 124 2969600
323650075 TurboDan E June 9, 2025, 2:39 p.m. OK Go TESTS 19 93 20172800
323604963 ifelsegawd E June 9, 2025, 9:09 a.m. OK Java 21 TESTS 19 249 15360000
323660483 WrongAnswerOnTestCase2 E June 9, 2025, 4:02 p.m. OK Java 21 TESTS 19 327 19046400
323665646 arjunspundir154 E June 9, 2025, 4:43 p.m. OK Java 21 TESTS 19 374 9830400
323652072 sulabhambule E June 9, 2025, 2:54 p.m. OK Java 21 TESTS 19 390 19865600
323645425 amit_roy E June 9, 2025, 2:06 p.m. OK Java 21 TESTS 19 421 15564800
323645375 priyaroy3370 E June 9, 2025, 2:05 p.m. OK Java 21 TESTS 19 421 15564800
323653204 parni6ka0 E June 9, 2025, 3:03 p.m. OK Java 21 TESTS 19 468 18124800
323612503 rheetiksharma603 E June 9, 2025, 10:02 a.m. OK Java 21 TESTS 19 499 50483200
323645078 69stranger69 E June 9, 2025, 2:03 p.m. OK Java 21 TESTS 19 500 49254400
323674888 bhanageviraj E June 9, 2025, 5:58 p.m. OK Java 21 TESTS 20 608 51404800
323681871 Pranav_45 E June 9, 2025, 7:03 p.m. OK Java 8 TESTS 20 218 12390400
323661772 Trouble_shooter E June 9, 2025, 4:13 p.m. OK Java 8 TESTS 19 233 10342400
323653253 ShengY E June 9, 2025, 3:04 p.m. OK Java 8 TESTS 19 233 17510400
323607270 bhishma_v2 E June 9, 2025, 9:24 a.m. OK Java 8 TESTS 19 264 8704000
323606990 sarthaKKharKa_18 E June 9, 2025, 9:22 a.m. OK Java 8 TESTS 19 311 19660800
323607751 bhishma_v2 E June 9, 2025, 9:27 a.m. OK Java 8 TESTS 19 312 8806400
323698785 cAtSiN E June 10, 2025, 1:21 a.m. OK Java 8 TESTS 20 593 0
323615182 Baidiki E June 9, 2025, 10:19 a.m. OK Java 8 TESTS 19 608 5529600
323653805 not_mohith E June 9, 2025, 3:08 p.m. OK Java 8 TESTS 19 608 5632000
323610554 gaurimadan002 E June 9, 2025, 9:48 a.m. OK Java 8 TESTS 19 624 5427200
323659293 chinesedfan E June 9, 2025, 3:52 p.m. OK Node.js TESTS 19 218 40448000
323712447 thinkphp E June 10, 2025, 5:02 a.m. OK PyPy 3 TESTS 20 515 17100800
323661814 shivamsai006 E June 9, 2025, 4:13 p.m. OK PyPy 3 TESTS 19 640 22323200
323626517 Ryan_10744 E June 9, 2025, 11:47 a.m. OK PyPy 3 TESTS 19 656 36864000
323653949 diudiu0903 E June 9, 2025, 3:09 p.m. OK PyPy 3-64 TESTS 19 202 39936000
323624346 velvetglove03 E June 9, 2025, 11:30 a.m. OK PyPy 3-64 TESTS 19 218 33484800
323615778 OAY71011 E June 9, 2025, 10:23 a.m. OK PyPy 3-64 TESTS 19 218 33587200
323617273 DivyamAwasthy E June 9, 2025, 10:35 a.m. OK PyPy 3-64 TESTS 19 249 32051200
323694700 hxu10 E June 9, 2025, 11:07 p.m. OK PyPy 3-64 TESTS 20 249 47616000
323615877 fractum_locum E June 9, 2025, 10:24 a.m. OK PyPy 3-64 TESTS 19 265 29798400
323657292 Vanekss E June 9, 2025, 3:37 p.m. OK PyPy 3-64 TESTS 19 265 31641600
323654470 udayan8 E June 9, 2025, 3:13 p.m. OK PyPy 3-64 TESTS 19 265 36864000
323648619 Ayis137 E June 9, 2025, 2:29 p.m. OK PyPy 3-64 TESTS 19 280 32768000
323623943 svrmalaviya E June 9, 2025, 11:27 a.m. OK PyPy 3-64 TESTS 19 281 31948800
323690329 sejutiii E June 9, 2025, 9:09 p.m. OK Python 3 TESTS 20 187 33177600
323618839 abhay_82 E June 9, 2025, 10:48 a.m. OK Python 3 TESTS 19 217 30822400
323679580 347586774 E June 9, 2025, 6:38 p.m. OK Python 3 TESTS 20 218 31129600
323705334 Anky1323 E June 10, 2025, 3:22 a.m. OK Python 3 TESTS 20 249 30720000
323695927 date727 E June 9, 2025, 11:51 p.m. OK Python 3 TESTS 20 265 31334400
323630523 huangjiajing E June 9, 2025, 12:17 p.m. OK Python 3 TESTS 19 421 31539200
323615670 ___a_s_1_2___ E June 9, 2025, 10:22 a.m. OK Python 3 TESTS 19 421 31744000
323641544 fucio E June 9, 2025, 1:36 p.m. OK Python 3 TESTS 19 671 60518400
323642125 amal064 E June 9, 2025, 1:40 p.m. OK Rust 2021 TESTS 19 93 4403200
323641377 ikr E June 9, 2025, 1:35 p.m. OK Rust 2021 TESTS 19 156 18841600

remove filters

Back to search problems