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 can never buy enough happiness, so here we go again! In this version, you can only buy h_i = 1 unit of happiness each month, but the number of months is hugely increased. We are in the realm of quantum happiness and time dilation. Being a physicist, Charlie likes to plan his life in simple and precise terms. For the next m months, starting with no money, Charlie will work hard and earn x pounds per month. For the i -th month (1 <= i <= m) , there'll be a single opportunity of paying cost c_i pounds to obtain one unit of happiness. You cannot buy more than one unit each month. Borrowing is not allowed. Money earned in the i -th month can only be spent in a later j -th month ( j>i ). Since physicists don't code, help Charlie find the maximum reachable units of happiness. The first line of the input contains t ( 1 <= q t <= q 10^4 ) -- the number of test cases. The first line of each test case contains two integers, m and x ( 1 <= m <= 2 cdot 10^5 , 1 <= x <= 10^3 ) -- the total number of months and the monthly salary. The second line of each test case contains m integers c_1, c_2, ... , c_m ( 1 <= q c_i <= q 10^3 ) -- the cost of one unit of happiness for each month. It is guaranteed that sum of m over all test cases does not exceed 2 cdot 10^5 . For each test case, output one integer -- the maximal amount of happiness Charlie can get. "... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
263494883 |
bati06 |
G |
May 31, 2024, 12:07 p.m. |
OK |
C# 10 |
TESTS |
29 |
155 |
19763200 |
|
2000 |
263218352 |
mban259 |
G |
May 30, 2024, 9:48 a.m. |
OK |
C# 10 |
TESTS |
29 |
202 |
22937600 |
|
2000 |
263089648 |
Sebastian1801 |
G |
May 29, 2024, 5:26 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
92 |
102400 |
|
2000 |
263250242 |
zerocloud01 |
G |
May 30, 2024, 12:48 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263131480 |
jainadit67 |
G |
May 29, 2024, 11:16 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263117287 |
ayuisaki |
G |
May 29, 2024, 9:18 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263097634 |
superDev007 |
G |
May 29, 2024, 6:45 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263089695 |
vjudge3 |
G |
May 29, 2024, 5:27 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
262985591 |
would1920 |
G |
May 28, 2024, 9:05 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
262670126 |
JKL891402 |
G |
May 26, 2024, 7:59 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263015955 |
yuehan |
G |
May 28, 2024, 1:15 p.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
819200 |
|
2000 |
263213714 |
Ashley_cy |
G |
May 30, 2024, 8:49 a.m. |
OK |
C++14 (GCC 6-32) |
TESTS |
29 |
93 |
3993600 |
|
2000 |
263076369 |
ahhde |
G |
May 29, 2024, 1:53 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
78 |
0 |
|
2000 |
262860236 |
Aibek-Zh-005-2026 |
G |
May 27, 2024, 9:53 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
78 |
102400 |
|
2000 |
263529238 |
HexStar |
G |
May 31, 2024, 4:54 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
78 |
819200 |
|
2000 |
263501440 |
KareemHatem |
G |
May 31, 2024, 12:59 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263409497 |
vjudge.9 |
G |
May 31, 2024, 4:36 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263409485 |
iced_T |
G |
May 31, 2024, 4:36 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263404733 |
190y |
G |
May 31, 2024, 3:38 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263190112 |
Mahm2od |
G |
May 29, 2024, 11:06 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263155234 |
SkareErik |
G |
May 29, 2024, 2:22 p.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
263125323 |
dhruv129 |
G |
May 29, 2024, 10:23 a.m. |
OK |
C++17 (GCC 7-32) |
TESTS |
29 |
93 |
0 |
|
2000 |
262987089 |
Sgdd |
G |
May 28, 2024, 9:17 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
62 |
819200 |
|
2000 |
263162543 |
LETTERA |
G |
May 29, 2024, 3:28 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
0 |
|
2000 |
262810277 |
Vince729 nikilrselvam skylinebaby waynetuinfor |
G |
May 27, 2024, 12:33 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
0 |
|
2000 |
262712932 |
Engineer |
G |
May 26, 2024, 1:54 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
0 |
|
2000 |
262712147 |
Arvi_saleque |
G |
May 26, 2024, 1:47 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
0 |
|
2000 |
262653989 |
rgnerdplayer |
G |
May 26, 2024, 5:48 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
0 |
|
2000 |
263403737 |
huangyuheng |
G |
May 31, 2024, 3:25 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
512000 |
|
2000 |
263687649 |
vjudge.3 |
G |
June 2, 2024, 12:18 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
614400 |
|
2000 |
263047878 |
Manjeet_Pathak |
G |
May 28, 2024, 5:40 p.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
614400 |
|
2000 |
262958461 |
SNX03 |
G |
May 28, 2024, 5 a.m. |
OK |
C++20 (GCC 13-64) |
TESTS |
29 |
77 |
614400 |
|
2000 |
263633654 |
c1415926 |
G |
June 1, 2024, 1:12 p.m. |
OK |
Java 21 |
TESTS |
29 |
296 |
2150400 |
|
2000 |
263401988 |
oneafter |
G |
May 31, 2024, 2:59 a.m. |
OK |
Java 21 |
TESTS |
29 |
296 |
3276800 |
|
2000 |
262912577 |
Tjha |
G |
May 27, 2024, 4:54 p.m. |
OK |
Java 21 |
TESTS |
29 |
327 |
3072000 |
|
2000 |
262635608 |
Orange905 |
G |
May 26, 2024, 1:41 a.m. |
OK |
Java 21 |
TESTS |
29 |
342 |
2048000 |
|
2000 |
262998970 |
daksh_02 |
G |
May 28, 2024, 11 a.m. |
OK |
Java 21 |
TESTS |
29 |
358 |
2457600 |
|
2000 |
262605843 |
codeWithDarshan |
G |
May 25, 2024, 5:05 p.m. |
OK |
Java 21 |
TESTS |
29 |
359 |
9011200 |
|
2000 |
263109973 |
jjjfr |
G |
May 29, 2024, 8:17 a.m. |
OK |
Java 21 |
TESTS |
29 |
406 |
15974400 |
|
2000 |
263214106 |
shivamarora09 |
G |
May 30, 2024, 8:54 a.m. |
OK |
Java 21 |
TESTS |
29 |
531 |
22732800 |
|
2000 |
263017145 |
pragyaat_goel |
G |
May 28, 2024, 1:24 p.m. |
OK |
Java 21 |
TESTS |
29 |
656 |
4096000 |
|
2000 |
263550295 |
RebibeMeJett |
G |
May 31, 2024, 8:56 p.m. |
OK |
Java 8 |
TESTS |
29 |
171 |
0 |
|
2000 |
262928905 |
yrgoudar |
G |
May 27, 2024, 7:44 p.m. |
OK |
Java 8 |
TESTS |
29 |
218 |
0 |
|
2000 |
263616890 |
1-1-1 |
G |
June 1, 2024, 10:56 a.m. |
OK |
Java 8 |
TESTS |
29 |
296 |
3993600 |
|
2000 |
263038726 |
MarcAS |
G |
May 28, 2024, 4:18 p.m. |
OK |
Java 8 |
TESTS |
29 |
406 |
0 |
|
2000 |
262906511 |
PlayDate |
G |
May 27, 2024, 4 p.m. |
OK |
Java 8 |
TESTS |
29 |
468 |
0 |
|
2000 |
262833148 |
tangzhenyu |
G |
May 27, 2024, 6:05 a.m. |
OK |
Java 8 |
TESTS |
29 |
514 |
0 |
|
2000 |
263305732 |
dgucs826 |
G |
May 30, 2024, 3:08 p.m. |
OK |
Java 8 |
TESTS |
29 |
530 |
9216000 |
|
2000 |
262762178 |
abbas_hammoud |
G |
May 26, 2024, 3:43 p.m. |
OK |
PyPy 3 |
TESTS |
29 |
437 |
17100800 |
|
2000 |
262839148 |
bergus |
G |
May 27, 2024, 6:59 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
171 |
24166400 |
|
2000 |
262838401 |
bergus |
G |
May 27, 2024, 6:54 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
202 |
26419200 |
|
2000 |
263125151 |
LoginovskiyE |
G |
May 29, 2024, 10:22 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
202 |
26521600 |
|
2000 |
262710999 |
liupengsay |
G |
May 26, 2024, 1:36 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
202 |
28569600 |
|
2000 |
263129013 |
Om_Singh_ |
G |
May 29, 2024, 10:55 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
202 |
29593600 |
|
2000 |
262760643 |
yuki_keshiki |
G |
May 26, 2024, 3:39 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
203 |
27545600 |
|
2000 |
262638336 |
samchen123 |
G |
May 26, 2024, 2:29 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
218 |
25702400 |
|
2000 |
262837934 |
bergus |
G |
May 27, 2024, 6:50 a.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
218 |
26214400 |
|
2000 |
263255197 |
Uncertainly |
G |
May 30, 2024, 1:24 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
218 |
26521600 |
|
2000 |
263176285 |
DarkTemplarDrop |
G |
May 29, 2024, 6:35 p.m. |
OK |
PyPy 3-64 |
TESTS |
29 |
233 |
27955200 |
|
2000 |
263128934 |
Om_Singh_ |
G |
May 29, 2024, 10:55 a.m. |
OK |
Python 3 |
TESTS |
29 |
186 |
27033600 |
|
2000 |
263501426 |
algotron |
G |
May 31, 2024, 12:58 p.m. |
OK |
Python 3 |
TESTS |
29 |
218 |
26112000 |
|
2000 |
262920410 |
RayenKad |
G |
May 27, 2024, 6:07 p.m. |
OK |
Python 3 |
TESTS |
29 |
218 |
26214400 |
|
2000 |
262930176 |
awesomep |
G |
May 27, 2024, 8:03 p.m. |
OK |
Python 3 |
TESTS |
29 |
233 |
25907200 |
|
2000 |
262509087 |
qyc333 |
G |
May 25, 2024, 12:28 p.m. |
OK |
Python 3 |
TESTS |
29 |
234 |
26112000 |
|
2000 |
262502290 |
NJIRTAI |
G |
May 25, 2024, 11:22 a.m. |
OK |
Python 3 |
TESTS |
29 |
265 |
32563200 |
|
2000 |
263260107 |
SughamKharel |
G |
May 30, 2024, 2:02 p.m. |
OK |
Python 3 |
TESTS |
29 |
281 |
26214400 |
|
2000 |
262815302 |
surendraparla |
G |
May 27, 2024, 2:36 a.m. |
OK |
Python 3 |
TESTS |
29 |
327 |
26214400 |
|
2000 |
263092739 |
BetterThanNobita |
G |
May 29, 2024, 6:02 a.m. |
OK |
Rust 2021 |
TESTS |
29 |
62 |
2150400 |
|
2000 |
262983764 |
rli43 |
G |
May 28, 2024, 8:49 a.m. |
OK |
Rust 2021 |
TESTS |
29 |
108 |
9318400 |
|
2000 |
remove filters
Back to search problems