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'An array is beautiful if both of the following two conditions meet: For example, the array [2, 3, 2, 4, 4, 3, 2] has 3 elements equal to its minimum ( 1 -st, 3 -rd and 7 -th) and 2 elements equal to its maximum ( 4 -th and 5 -th). Another example: the array [42, 42, 42] has 3 elements equal to its minimum and 3 elements equal to its maximum. Your task is to calculate the minimum possible number of elements in a beautiful array. The first line contains one integer t ( 1 <= t <= 5000 ) -- the number of test cases. Each test case consists of one line containing four integers l_1 , r_1 , l_2 and r_2 ( 1 <= l_1 <= r_1 <= 50 ; 1 <= l_2 <= r_2 <= 50 ). For each test case, print one integer -- the minimum possible number of elements in a beautiful array. Optimal arrays in the test cases of the example: '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
157066619 |
Dineshraj |
A |
May 13, 2022, 4:14 p.m. |
OK |
C# 8 |
TESTS |
6 |
124 |
1536000 |
|
|
157117105 |
bijinacm |
A |
May 14, 2022, 5:52 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
0 |
|
|
157117030 |
StaleMate30 |
A |
May 14, 2022, 5:51 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
0 |
|
|
157115379 |
sjain108 |
A |
May 14, 2022, 5:27 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
0 |
|
|
157112694 |
7as__7 |
A |
May 14, 2022, 4:39 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
0 |
|
|
157104867 |
Carey_Knight |
A |
May 14, 2022, 1:53 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
0 |
|
|
157103392 |
vjudge4 |
A |
May 14, 2022, 1:12 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
0 |
|
|
157103135 |
vjudge4 |
A |
May 14, 2022, 1:04 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
0 |
|
|
157080473 |
saltine_salad |
A |
May 13, 2022, 5:24 p.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
0 |
|
|
157107939 |
Mr__Peanutbutter |
A |
May 14, 2022, 3:05 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
0 |
102400 |
|
|
157117613 |
Ashap_Bappy |
A |
May 14, 2022, 5:58 a.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
0 |
|
|
remove filters
Back to search problems