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.
Problems
B'You are given a string consisting of characters 0 and/or 1. You have to paint every character of this string into one of two colors, red or blue. If you paint the i -th character red, you get r_i coins. If you paint it blue, you get b_i coins. After coloring the string, you remove every blue character from it, and count the number of inversions in the resulting string (i. xe2 x80 x89e. the number of pairs of characters such that the left character in the pair is 1, and the right character in the pair is 0). For each inversion, you have to pay 1 coin. What is the maximum number of coins you can earn? The first line of the input contains one integer t ( 1 <= t <= 10^4 ) -- the number of test cases. Each test case consists of four lines: Additional constraint on the input: the sum of values of n over all test cases does not exceed 4 cdot 10^5 . For each test case, print one integer -- the maximum number of coins you can earn. Explanations for the test cases for the example (blue characters are underlined, red ones are not): '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
231273887 |
itz_sam |
G |
Nov. 4, 2023, 4:09 a.m. |
OK |
GNU C11 |
TESTS |
114 |
561 |
16486400 |
|
|
231249117 |
Sparkle_Twilight |
G |
Nov. 3, 2023, 9:15 p.m. |
OK |
GNU C11 |
TESTS |
114 |
576 |
16486400 |
|
|
231272805 |
QWERTY_123456 |
G |
Nov. 4, 2023, 3:54 a.m. |
OK |
GNU C++17 |
TESTS |
114 |
530 |
14028800 |
|
|
231233074 |
ahmed.gamal007 |
G |
Nov. 3, 2023, 7:06 p.m. |
OK |
GNU C++17 |
TESTS |
114 |
623 |
16384000 |
|
|
231266703 |
SCOIandNOI2024_lets_go |
G |
Nov. 4, 2023, 2:33 a.m. |
OK |
GNU C++17 |
TESTS |
114 |
1481 |
26112000 |
|
|
231213313 |
hitonanode |
G |
Nov. 3, 2023, 5:16 p.m. |
OK |
GNU C++17 (64) |
TESTS |
114 |
405 |
57139200 |
|
|
231273875 |
tute7627 |
G |
Nov. 4, 2023, 4:09 a.m. |
OK |
GNU C++17 (64) |
TESTS |
114 |
436 |
25292800 |
|
|
231214703 |
hitonanode |
G |
Nov. 3, 2023, 5:24 p.m. |
OK |
GNU C++17 (64) |
TESTS |
114 |
499 |
155443200 |
|
|
231210500 |
noimi |
G |
Nov. 3, 2023, 4:58 p.m. |
OK |
GNU C++17 (64) |
TESTS |
114 |
514 |
38092800 |
|
|
231213900 |
hitonanode |
G |
Nov. 3, 2023, 5:20 p.m. |
OK |
GNU C++17 (64) |
TESTS |
114 |
514 |
167731200 |
|
|
231236868 |
chappy1 |
G |
Nov. 3, 2023, 7:28 p.m. |
OK |
GNU C++17 (64) |
TESTS |
114 |
919 |
53145600 |
|
|
231266743 |
grass8sheep |
G |
Nov. 4, 2023, 2:34 a.m. |
OK |
GNU C++17 (64) |
TESTS |
114 |
1684 |
26112000 |
|
|
231266872 |
aryan.kadyrov |
G |
Nov. 4, 2023, 2:36 a.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
264 |
16076800 |
|
|
231278882 |
theibrahim |
G |
Nov. 4, 2023, 5:18 a.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
312 |
16076800 |
|
|
231214354 |
noimi |
G |
Nov. 3, 2023, 5:22 p.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
576 |
30515200 |
|
|
231206538 |
PacificGirl |
G |
Nov. 3, 2023, 4:38 p.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
1060 |
83148800 |
|
|
231246603 |
Yu_Yu_fish |
G |
Nov. 3, 2023, 8:44 p.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
1123 |
16384000 |
|
|
231215962 |
zhdmm |
G |
Nov. 3, 2023, 5:33 p.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
1231 |
16384000 |
|
|
231258250 |
magnus.hegdahl |
G |
Nov. 4, 2023, 12:20 a.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
3540 |
8704000 |
|
|
231258498 |
magnus.hegdahl |
G |
Nov. 4, 2023, 12:27 a.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
3619 |
9113600 |
|
|
231258702 |
magnus.hegdahl |
G |
Nov. 4, 2023, 12:31 a.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
3744 |
9113600 |
|
|
231258330 |
magnus.hegdahl |
G |
Nov. 4, 2023, 12:22 a.m. |
OK |
GNU C++20 (64) |
TESTS |
114 |
3759 |
9113600 |
|
|
remove filters
Back to search problems