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"Alice and Bob are playing a game. Initially, there are n cakes, with the i -th cake having a tastiness value of a_i . Alice and Bob take turns eating them, with Alice starting first: The game ends when the current player can't eat a suitable cake. Let x be the number of cakes that Alice ate. Then, Alice wants to maximize x , while Bob wants to minimize x . Find out how many cakes Alice will eat if both players play optimally. Each test contains multiple test cases. The first line of input contains a single integer t ( 1 <= t <= 500 ) -- the number of test cases. The description of the test cases follows. The first line of each test case contains a single integer n ( 1 <= n <= 5000 ) -- the number of cakes. The second line of each test case contains n integers a_1, a_2, ldots, a_n ( 1 <= a_i <= n ) -- the tastiness values of the cakes. It is guaranteed that the sum of n over all test cases does not exceed 5000 . For each test case, output a single integer -- the number of cakes Alice will eat if both players play optimally. In the first test case, one possible sequence of turns is: In the second test case, one possible sequence of turns is: "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
268246809 |
Simex |
D |
July 1, 2024, 12:37 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
46 |
102400 |
|
|
268236372 |
Chaawal25 |
D |
June 30, 2024, 8:50 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
61 |
0 |
|
|
268249907 |
chaoslong |
D |
July 1, 2024, 1:42 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
92 |
2457600 |
|
|
268215830 |
wodyfor |
D |
June 30, 2024, 5:22 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
93 |
102400 |
|
|
268246894 |
BINYU |
D |
July 1, 2024, 12:39 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
93 |
100454400 |
|
|
268256129 |
DEAD_TCT |
D |
July 1, 2024, 3:21 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
124 |
100454400 |
|
|
268213691 |
tarunkumar1478 |
D |
June 30, 2024, 5:15 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
155 |
96972800 |
|
|
268248936 |
caidx |
D |
July 1, 2024, 1:22 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
156 |
96768000 |
|
|
268210307 |
taochenyu |
D |
June 30, 2024, 5:04 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
187 |
100352000 |
|
|
268228167 |
dvpknsxp |
D |
June 30, 2024, 7:04 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
23 |
202 |
96870400 |
|
|
268267218 |
chaitanya_2408 |
D |
July 1, 2024, 5:36 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
46 |
0 |
|
|
268263280 |
_Omar.Yehia_ |
D |
July 1, 2024, 4:49 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
46 |
0 |
|
|
268244972 |
mayawan |
D |
June 30, 2024, 11:53 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
46 |
0 |
|
|
268263192 |
hshhh_ |
D |
July 1, 2024, 4:48 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
46 |
102400 |
|
|
268264861 |
AKStream |
D |
July 1, 2024, 5:10 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
61 |
0 |
|
|
268258394 |
yuan-shen |
D |
July 1, 2024, 3:51 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
61 |
0 |
|
|
268245832 |
sephiroth0201 |
D |
July 1, 2024, 12:14 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
61 |
0 |
|
|
268256351 |
polariscyy |
D |
July 1, 2024, 3:24 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
61 |
102400 |
|
|
268251623 |
Ether13 |
D |
July 1, 2024, 2:13 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
61 |
102400 |
|
|
268265523 |
RomRomBhaiyo |
D |
July 1, 2024, 5:18 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
23 |
61 |
7987200 |
|
|
268265477 |
Sabhya_Arora |
D |
July 1, 2024, 5:17 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268264227 |
FangYifan |
D |
July 1, 2024, 5:01 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268258440 |
FangYifan |
D |
July 1, 2024, 3:51 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268258423 |
Rohak |
D |
July 1, 2024, 3:51 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268255519 |
Homie_Lander |
D |
July 1, 2024, 3:13 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268246642 |
codicon |
D |
July 1, 2024, 12:33 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268245044 |
MongyTrad |
D |
June 30, 2024, 11:55 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268243870 |
Ahmed_El_Gendy |
D |
June 30, 2024, 11:24 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268232957 |
EthanZYF |
D |
June 30, 2024, 8:02 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
0 |
|
|
268267561 |
Ackv111 |
D |
July 1, 2024, 5:39 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
23 |
46 |
102400 |
|
|
268241596 |
rainboy |
D |
June 30, 2024, 10:28 p.m. |
OK |
GNU C11 |
TESTS |
23 |
46 |
102400 |
|
|
268207912 |
barnwal123 |
D |
June 30, 2024, 4:57 p.m. |
OK |
GNU C11 |
TESTS |
23 |
812 |
201728000 |
|
|
268219047 |
sidsrf |
D |
June 30, 2024, 5:31 p.m. |
OK |
GNU C11 |
TESTS |
23 |
874 |
201728000 |
|
|
268208405 |
anirudhcf |
D |
June 30, 2024, 4:58 p.m. |
OK |
GNU C11 |
TESTS |
23 |
905 |
200908800 |
|
|
268237038 |
dzhi |
D |
June 30, 2024, 9 p.m. |
OK |
Java 21 |
TESTS |
23 |
218 |
1536000 |
|
|
268226610 |
nathanballman |
D |
June 30, 2024, 6:46 p.m. |
OK |
Java 21 |
TESTS |
23 |
296 |
409600 |
|
|
268237172 |
amaturecoder |
D |
June 30, 2024, 9:02 p.m. |
OK |
Java 21 |
TESTS |
23 |
296 |
614400 |
|
|
268236015 |
CipherSphinx_Raj |
D |
June 30, 2024, 8:45 p.m. |
OK |
Java 21 |
TESTS |
23 |
312 |
42496000 |
|
|
268235974 |
__runknowna__ |
D |
June 30, 2024, 8:44 p.m. |
OK |
Java 21 |
TESTS |
23 |
312 |
42496000 |
|
|
268249150 |
MaxBuzz |
D |
July 1, 2024, 1:26 a.m. |
OK |
Java 21 |
TESTS |
23 |
375 |
157900800 |
|
|
268237833 |
susvant |
D |
June 30, 2024, 9:13 p.m. |
OK |
Java 21 |
TESTS |
23 |
405 |
142745600 |
|
|
268209858 |
GoldenShadow |
D |
June 30, 2024, 5:03 p.m. |
OK |
Java 21 |
TESTS |
23 |
437 |
204800 |
|
|
268259715 |
Laksh21262 |
D |
July 1, 2024, 4:06 a.m. |
OK |
Java 21 |
TESTS |
23 |
437 |
76083200 |
|
|
268233244 |
SD125 |
D |
June 30, 2024, 8:06 p.m. |
OK |
Java 21 |
TESTS |
23 |
453 |
157900800 |
|
|
268214994 |
ayush11.kr_ |
D |
June 30, 2024, 5:19 p.m. |
OK |
Java 8 |
TESTS |
23 |
437 |
147046400 |
|
|
268209576 |
yadavDipesh |
D |
June 30, 2024, 5:02 p.m. |
OK |
Java 8 |
TESTS |
23 |
624 |
143462400 |
|
|
268237170 |
PlayDate |
D |
June 30, 2024, 9:02 p.m. |
OK |
Java 8 |
TESTS |
23 |
656 |
147558400 |
|
|
268213755 |
vatsal_04 |
D |
June 30, 2024, 5:15 p.m. |
OK |
Java 8 |
TESTS |
23 |
968 |
144486400 |
|
|
268227857 |
ilovenandini |
D |
June 30, 2024, 7 p.m. |
OK |
Java 8 |
TESTS |
23 |
1218 |
261632000 |
|
|
268216831 |
ag_pulkit |
D |
June 30, 2024, 5:25 p.m. |
OK |
Java 8 |
TESTS |
23 |
1390 |
260915200 |
|
|
268209808 |
sumanth.badugu07 |
D |
June 30, 2024, 5:03 p.m. |
OK |
Java 8 |
TESTS |
23 |
1561 |
260812800 |
|
|
268219135 |
kush_1719 |
D |
June 30, 2024, 5:31 p.m. |
OK |
Java 8 |
TESTS |
23 |
1686 |
260915200 |
|
|
268225765 |
ahtoh_ |
D |
June 30, 2024, 6:39 p.m. |
OK |
Node.js |
TESTS |
23 |
343 |
10035200 |
|
|
268215530 |
TychoElling |
D |
June 30, 2024, 5:21 p.m. |
OK |
PyPy 3 |
TESTS |
23 |
218 |
4710400 |
|
|
268209593 |
mahnameisayush |
D |
June 30, 2024, 5:02 p.m. |
OK |
PyPy 3 |
TESTS |
23 |
483 |
6144000 |
|
|
268214309 |
rmittal |
D |
June 30, 2024, 5:17 p.m. |
OK |
PyPy 3 |
TESTS |
23 |
999 |
104960000 |
|
|
268242520 |
jvatsal0709 |
D |
June 30, 2024, 10:50 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
124 |
3276800 |
|
|
268246235 |
cybsbbb |
D |
July 1, 2024, 12:24 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
125 |
3891200 |
|
|
268216858 |
RobinFromTheHood |
D |
June 30, 2024, 5:25 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
140 |
3891200 |
|
|
268224990 |
34z12000 |
D |
June 30, 2024, 6:35 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
202 |
3276800 |
|
|
268233741 |
Antriksh07 |
D |
June 30, 2024, 8:12 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
203 |
3891200 |
|
|
268251356 |
Gardenia625 |
D |
July 1, 2024, 2:09 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
218 |
4505600 |
|
|
268208221 |
luismriq |
D |
June 30, 2024, 4:58 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
233 |
3584000 |
|
|
268250309 |
Jin_Silk |
D |
July 1, 2024, 1:50 a.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
249 |
3174400 |
|
|
268209651 |
Silence_the_Paradigmatic |
D |
June 30, 2024, 5:02 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
264 |
9318400 |
|
|
268227486 |
PenguinSlayer_69 |
D |
June 30, 2024, 6:56 p.m. |
OK |
PyPy 3-64 |
TESTS |
23 |
280 |
6860800 |
|
|
268210151 |
Deepanshu_2020051 |
D |
June 30, 2024, 5:04 p.m. |
OK |
Scala |
TESTS |
23 |
1999 |
253030400 |
|
|
remove filters
Back to search problems