Codeforces Round 1031 (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
2113 Codeforces Round 1031 (Div. 2) FINISHED False 7200 26427323 June 15, 2025, 9:05 a.m.

Problems

Solved
Index
Name
Type
Tags
Community Tag
Rating
( 2859 ) D Cheater PROGRAMMING binary search constructive algorithms data structures greedy

You are playing a new card game in a casino with the following rules: The game uses a deck of (2n) cards with different values. The deck is evenly split between the player and the dealer: each receives (n) cards. Over (n) rounds, the player and the dealer simultaneously play one top card from their hand. The cards are compared, and the point goes to the one whose card has a higher value. The winning card is removed from the game, while the losing card is returned to the hand and placed on top of the other cards in the hand of the player who played it. Note that the game always lasts exactly (n) rounds. You have tracked the shuffling of the cards and know the order of the cards in the dealer's hand (from top to bottom). You want to maximize your score, so you can swap any two cards in your hand no more than once (to avoid raising suspicion). Determine the maximum number of points you can achieve. Each test contains multiple test cases. The first line contains the number of test cases (t) ((1 \le t \le 5 \cdot 10^4)). The description of the test cases follows. The first line of each test case contains a single integer (n) ((1 \leq n \leq 2 \cdot 10^{5})) — the number of cards in the player's hand. The second line of each test case contains (n) integers (a_{1}, a_{2}, \ldots, a_{n}) ((1 \leq a_{i} \leq 2n)) — the values of the cards in the player's hand from top to bottom. The third line of each test case contains (n) integers (b_{1}, b_{2}, \ldots, b_{n}) ((1 \leq b_{i} \leq 2n)) — the values of the cards in the dealer's hand from top to bottom. It is guaranteed that the values of all cards are distinct. It is guaranteed that the sum of (n) over all test cases does not exceed (2 \cdot 10^5). For each test case, output a single integer — the maximum number of points you can achieve. In the first test case, the cards can remain unchanged. The gameplay will be organized as follows: The cards with v

Tutorials

Codeforces Round #1031 Editorial

Submissions

Submission Id
Author(s)
Index
Submitted
Verdict
Language
Test Set
Tests Passed
Time taken (ms)
Memory Consumed (bytes)
Tags
Rating
324522099 og.kostya D June 15, 2025, 12:07 p.m. OK C# 10 TESTS 24 93 3072000
324522060 og.kostya D June 15, 2025, 12:07 p.m. OK C# 13 TESTS 24 140 3686400
324537132 -firefly- D June 15, 2025, 2:33 p.m. OK C# 13 TESTS 24 187 3584000
324578031 Pinkyhead D June 16, 2025, 12:24 a.m. OK C++17 (GCC 7-32) TESTS 24 109 1638400
324580672 W_Franklin D June 16, 2025, 1:37 a.m. OK C++17 (GCC 7-32) TESTS 24 109 3276800
324581987 akshitGg D June 16, 2025, 2:04 a.m. OK C++17 (GCC 7-32) TESTS 24 124 0
324522479 Prady D June 15, 2025, 12:11 p.m. OK C++17 (GCC 7-32) TESTS 24 124 0
324586723 Nathan661 D June 16, 2025, 3:19 a.m. OK C++17 (GCC 7-32) TESTS 24 124 102400
324540734 cannadagrammo D June 15, 2025, 3:04 p.m. OK C++17 (GCC 7-32) TESTS 24 124 102400
324588859 Nathan661 D June 16, 2025, 3:44 a.m. OK C++17 (GCC 7-32) TESTS 24 124 1126400
324582695 vnedu D June 16, 2025, 2:18 a.m. OK C++17 (GCC 7-32) TESTS 24 124 1638400
324582649 zh1221qwq D June 16, 2025, 2:17 a.m. OK C++17 (GCC 7-32) TESTS 24 124 1638400
324538586 yud08 D June 15, 2025, 2:47 p.m. OK C++17 (GCC 7-32) TESTS 24 125 0
324515337 kktmg2 D June 15, 2025, 11:24 a.m. OK C++20 (GCC 13-64) TESTS 24 108 102400
324597462 suzumi D June 16, 2025, 5:39 a.m. OK C++20 (GCC 13-64) TESTS 24 108 32153600
324584432 Satyam_Atal_605 D June 16, 2025, 2:49 a.m. OK C++20 (GCC 13-64) TESTS 24 109 0
324583701 Muschuang123 D June 16, 2025, 2:37 a.m. OK C++20 (GCC 13-64) TESTS 24 109 102400
324573796 captainburkinafaso D June 15, 2025, 9:48 p.m. OK C++20 (GCC 13-64) TESTS 24 109 102400
324522522 rikel_pik D June 15, 2025, 12:11 p.m. OK C++20 (GCC 13-64) TESTS 24 109 102400
324519516 Incredible0306 D June 15, 2025, noon OK C++20 (GCC 13-64) TESTS 24 109 102400
324518104 raghav.bharathi D June 15, 2025, 11:46 a.m. OK C++20 (GCC 13-64) TESTS 24 109 102400
324517506 SaltyDonut D June 15, 2025, 11:40 a.m. OK C++20 (GCC 13-64) TESTS 24 109 102400
324516570 BaarishBoy D June 15, 2025, 11:33 a.m. OK C++20 (GCC 13-64) TESTS 24 109 102400
324526004 maspy D June 15, 2025, 12:45 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 62 307200
324517996 kanglr1013 D June 15, 2025, 11:45 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 77 2662400
324578944 AEM_YNxingkong D June 16, 2025, 12:55 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 77 3481600
324586417 flowing_boat D June 16, 2025, 3:16 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 93 11161600
324516552 goats_9 D June 15, 2025, 11:32 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 108 0
324589918 klein31415 D June 16, 2025, 3:57 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 108 102400
324516799 slashTeen D June 15, 2025, 11:35 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 108 102400
324515913 Kirkon D June 15, 2025, 11:28 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 108 102400
324516333 MarcosK D June 15, 2025, 11:31 a.m. OK C++23 (GCC 14-64, msys2) TESTS 24 108 4096000
324572077 YouKn0wMe2005 D June 15, 2025, 9:03 p.m. OK C++23 (GCC 14-64, msys2) TESTS 24 109 0
324515553 klm_ztv D June 15, 2025, 11:25 a.m. OK GNU C11 TESTS 24 109 1638400
324517398 redreoicy D June 15, 2025, 11:40 a.m. OK Java 21 TESTS 24 358 4710400
324515580 lyongwolf D June 15, 2025, 11:25 a.m. OK Java 21 TESTS 24 374 34304000
324552002 sad_truant D June 15, 2025, 4:42 p.m. OK Java 21 TESTS 24 421 25292800
324540710 sad_truant D June 15, 2025, 3:04 p.m. OK Java 21 TESTS 24 436 25395200
324516802 wddd D June 15, 2025, 11:35 a.m. OK Java 21 TESTS 24 437 10137600
324526365 believer_0507 D June 15, 2025, 12:49 p.m. OK Java 21 TESTS 24 515 40755200
324543188 dusty.and.rusty D June 15, 2025, 3:24 p.m. OK Java 21 TESTS 24 546 17408000
324555669 dusty.and.rusty D June 15, 2025, 5:18 p.m. OK Java 21 TESTS 24 687 17408000
324509154 LMeyling D June 15, 2025, 10:56 a.m. OK PyPy 3-64 TESTS 24 234 32563200
324516309 kavorka D June 15, 2025, 11:30 a.m. OK PyPy 3-64 TESTS 24 249 22323200
324527069 347586774 D June 15, 2025, 12:56 p.m. OK PyPy 3-64 TESTS 24 249 34713600
324536378 KAMITO D June 15, 2025, 2:27 p.m. OK PyPy 3-64 TESTS 24 281 35328000
324590978 siuhou D June 16, 2025, 4:09 a.m. OK PyPy 3-64 TESTS 24 312 33177600
324527347 Remineva D June 15, 2025, 12:59 p.m. OK PyPy 3-64 TESTS 24 327 28774400
324517908 sushmanth.dampur8780 D June 15, 2025, 11:45 a.m. OK PyPy 3-64 TESTS 24 327 35532800
324528074 347586774 D June 15, 2025, 1:07 p.m. OK PyPy 3-64 TESTS 24 343 32460800
324517568 sushmanth.dampur8780 D June 15, 2025, 11:41 a.m. OK PyPy 3-64 TESTS 24 374 35635200
324590619 siuhou D June 16, 2025, 4:04 a.m. OK PyPy 3-64 TESTS 24 390 31948800
324528511 Mayank_jindal D June 15, 2025, 1:12 p.m. OK Python 3 TESTS 24 609 34611200
324518924 svrmalaviya D June 15, 2025, 11:54 a.m. OK Python 3 TESTS 24 624 31846400
324551023 sad_truant D June 15, 2025, 4:32 p.m. OK Rust 2021 TESTS 24 78 3993600
324551630 sad_truant D June 15, 2025, 4:38 p.m. OK Rust 2021 TESTS 24 108 2867200

remove filters

Back to search problems