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'Let s be a string of lowercase Latin letters. Its price is the sum of the indices of letters (an integer between 1 and 26) that are included in it. For example, the price of the string abca is 1+2+3+1=7 . The string w and the integer p are given. Remove the minimal number of letters from w so that its price becomes less than or equal to p and print the resulting string. Note that the resulting string may be empty. You can delete arbitrary letters, they do not have to go in a row. If the price of a given string w is less than or equal to p , then nothing needs to be deleted and w must be output. Note that when you delete a letter from w , the order of the remaining letters is preserved. For example, if you delete the letter e from the string test, you get tst. The first line of input contains an integer t ( 1 <= t <= 10^4 ) -- the number of test cases in the test. The following are descriptions of t test cases. Each case consists of two lines. The first of them is the string w , it is non-empty and consists of lowercase Latin letters. Its length does not exceed 2 cdot10^5 . The second line contains an integer p ( 1 <= p <= 5 ,200 ,000 ). It is guaranteed that the sum of string lengths w over all test cases does not exceed 2 cdot 10^5 . Output exactly t rows, the i -th of them should contain the answer to the i -th set of input data. Print the longest string that is obtained from w by deleting letters such that its price is less or equal to p . If there are several answers, then output any of them. Note that the empty string -- is one of the possible answers. In this case, just output an empty string. '... |
Tutorials
Submissions
Submission Id |
Author(s) |
Index |
Submitted |
Verdict |
Language |
Test Set |
Tests Passed |
Time taken (ms) |
Memory Consumed (bytes) |
Tags |
Rating |
163584078 |
chrisfcoder |
D |
July 10, 2022, 5:16 p.m. |
OK |
C# 10 |
TESTS |
6 |
46 |
3072000 |
|
|
163607770 |
bluemegane |
D |
July 11, 2022, 12:43 a.m. |
OK |
C# 8 |
TESTS |
13 |
140 |
17203200 |
|
|
163583271 |
Jingfan.K |
D |
July 10, 2022, 5:10 p.m. |
OK |
GNU C11 |
TESTS |
6 |
733 |
21094400 |
|
|
163612894 |
2915584233 |
D |
July 11, 2022, 2:22 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
15 |
204800 |
|
|
163611998 |
YaoLingF |
D |
July 11, 2022, 2:06 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
15 |
204800 |
|
|
163611978 |
YaoLingF |
D |
July 11, 2022, 2:06 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
15 |
204800 |
|
|
163626931 |
jangjie |
D |
July 11, 2022, 5:42 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
15 |
204800 |
|
|
163626854 |
zstu21yuanchang |
D |
July 11, 2022, 5:42 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
15 |
204800 |
|
|
163622819 |
HLY111 |
D |
July 11, 2022, 4:50 a.m. |
OK |
GNU C++14 |
TESTS |
13 |
15 |
204800 |
|
|
163597553 |
MrsGrace |
D |
July 10, 2022, 8:06 p.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
512000 |
|
|
163594427 |
pranshukas |
D |
July 10, 2022, 7:13 p.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
512000 |
|
|
163591133 |
ayushnautiyal1110 |
D |
July 10, 2022, 6:26 p.m. |
OK |
GNU C++14 |
TESTS |
6 |
15 |
512000 |
|
|
163603248 |
aliaagheis |
D |
July 10, 2022, 10:18 p.m. |
OK |
GNU C++14 |
TESTS |
13 |
15 |
512000 |
|
|
163614467 |
witw |
D |
July 11, 2022, 2:46 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
204800 |
|
|
163626638 |
Gevin |
D |
July 11, 2022, 5:39 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
204800 |
|
|
163620736 |
Hugh5916 |
D |
July 11, 2022, 4:18 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
307200 |
|
|
163628568 |
Sempr |
D |
July 11, 2022, 6 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
409600 |
|
|
163625854 |
Horb7 |
D |
July 11, 2022, 5:30 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
512000 |
|
|
163623045 |
M_A_R |
D |
July 11, 2022, 4:53 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
512000 |
|
|
163620791 |
bgg0516 |
D |
July 11, 2022, 4:19 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
512000 |
|
|
163620592 |
Vu_CG_Coder |
D |
July 11, 2022, 4:16 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
512000 |
|
|
163618888 |
ArtieAaron |
D |
July 11, 2022, 3:50 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
512000 |
|
|
163628144 |
binary_bae |
D |
July 11, 2022, 5:55 a.m. |
OK |
GNU C++17 |
TESTS |
13 |
15 |
512000 |
|
|
163597285 |
dgupta0812 |
D |
July 10, 2022, 8 p.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
512000 |
|
|
163628718 |
eggag32 |
D |
July 11, 2022, 6:02 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163625565 |
sajin10 |
D |
July 11, 2022, 5:27 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163624239 |
YDNB |
D |
July 11, 2022, 5:09 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163618268 |
___dreamer__ |
D |
July 11, 2022, 3:40 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163613340 |
Time_JYF |
D |
July 11, 2022, 2:30 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163607272 |
RetsaZC19 |
D |
July 11, 2022, 12:29 a.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163601643 |
jesse_pinkman_619 |
D |
July 10, 2022, 9:33 p.m. |
OK |
GNU C++17 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163598280 |
Olympia |
D |
July 10, 2022, 8:18 p.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
512000 |
|
|
163592119 |
enslaved |
D |
July 10, 2022, 6:40 p.m. |
OK |
GNU C++17 (64) |
TESTS |
6 |
15 |
512000 |
|
|
163593103 |
S_Neal |
D |
July 10, 2022, 6:53 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
512000 |
|
|
163612023 |
Sorry_Hanasaki |
D |
July 11, 2022, 2:06 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
0 |
512000 |
|
|
163589883 |
Dhruv_24 |
D |
July 10, 2022, 6:12 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
512000 |
|
|
163586442 |
AhmedSofi |
D |
July 10, 2022, 5:36 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
512000 |
|
|
163584568 |
shiro |
D |
July 10, 2022, 5:19 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
512000 |
|
|
163597527 |
Aman23Sriv |
D |
July 10, 2022, 8:05 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
512000 |
|
|
163593653 |
juniorcompressor |
D |
July 10, 2022, 7:01 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
819200 |
|
|
163596267 |
ghannu |
D |
July 10, 2022, 7:42 p.m. |
OK |
GNU C++20 (64) |
TESTS |
6 |
0 |
819200 |
|
|
163620835 |
yangster67 |
D |
July 11, 2022, 4:20 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163623459 |
bedi_1234 |
D |
July 11, 2022, 4:58 a.m. |
OK |
GNU C++20 (64) |
TESTS |
13 |
15 |
512000 |
|
|
163602996 |
megabluejay |
D |
July 10, 2022, 10:10 p.m. |
OK |
Haskell |
TESTS |
13 |
202 |
44134400 |
|
|
163618712 |
vamshisamineni3 |
D |
July 11, 2022, 3:47 a.m. |
OK |
Java 11 |
TESTS |
13 |
171 |
0 |
|
|
163589339 |
deepakjoshi6102 |
D |
July 10, 2022, 6:05 p.m. |
OK |
Java 11 |
TESTS |
6 |
187 |
0 |
|
|
163624182 |
Hitesh_Ahuja |
D |
July 11, 2022, 5:08 a.m. |
OK |
Java 11 |
TESTS |
13 |
202 |
0 |
|
|
163613827 |
nis1234 |
D |
July 11, 2022, 2:36 a.m. |
OK |
Java 11 |
TESTS |
13 |
233 |
0 |
|
|
163590153 |
Kushal_Juneja |
D |
July 10, 2022, 6:15 p.m. |
OK |
Java 11 |
TESTS |
6 |
233 |
0 |
|
|
163612267 |
djrfrn |
D |
July 11, 2022, 2:11 a.m. |
OK |
Java 11 |
TESTS |
13 |
234 |
0 |
|
|
163625230 |
amitmandal |
D |
July 11, 2022, 5:23 a.m. |
OK |
Java 11 |
TESTS |
13 |
249 |
3174400 |
|
|
163607693 |
enricogi |
D |
July 11, 2022, 12:41 a.m. |
OK |
Java 11 |
TESTS |
13 |
280 |
0 |
|
|
163591562 |
Smriti_Gupta |
D |
July 10, 2022, 6:31 p.m. |
OK |
Java 11 |
TESTS |
6 |
296 |
3276800 |
|
|
163621620 |
rishabhpanchal |
D |
July 11, 2022, 4:33 a.m. |
OK |
Java 11 |
TESTS |
13 |
311 |
17305600 |
|
|
163599719 |
Mamimi |
D |
July 10, 2022, 8:46 p.m. |
OK |
Java 17 |
TESTS |
13 |
202 |
614400 |
|
|
163591152 |
soumit915 |
D |
July 10, 2022, 6:26 p.m. |
OK |
Java 17 |
TESTS |
6 |
234 |
0 |
|
|
163627473 |
Koushik16 |
D |
July 11, 2022, 5:48 a.m. |
OK |
Java 17 |
TESTS |
13 |
296 |
716800 |
|
|
163600673 |
Eslam_Ahmed |
D |
July 10, 2022, 9:08 p.m. |
OK |
Java 17 |
TESTS |
13 |
405 |
17920000 |
|
|
163604734 |
Sussykin |
D |
July 10, 2022, 11:03 p.m. |
OK |
Java 8 |
TESTS |
13 |
108 |
0 |
|
|
163590927 |
priyaroy3370 |
D |
July 10, 2022, 6:23 p.m. |
OK |
Java 8 |
TESTS |
6 |
108 |
0 |
|
|
163590613 |
kareem3id |
D |
July 10, 2022, 6:20 p.m. |
OK |
Java 8 |
TESTS |
6 |
109 |
0 |
|
|
163583910 |
Parimal |
D |
July 10, 2022, 5:15 p.m. |
OK |
Java 8 |
TESTS |
6 |
109 |
0 |
|
|
163587729 |
r3hab.rs |
D |
July 10, 2022, 5:48 p.m. |
OK |
Java 8 |
TESTS |
6 |
140 |
0 |
|
|
163596712 |
Mohamed_A7med |
D |
July 10, 2022, 7:50 p.m. |
OK |
Java 8 |
TESTS |
6 |
155 |
4608000 |
|
|
163603797 |
AbdelrahmanFathy |
D |
July 10, 2022, 10:33 p.m. |
OK |
Java 8 |
TESTS |
13 |
170 |
0 |
|
|
163609233 |
T-error |
D |
July 11, 2022, 1:15 a.m. |
OK |
Java 8 |
TESTS |
13 |
171 |
0 |
|
|
163587789 |
swaggy_baba |
D |
July 10, 2022, 5:49 p.m. |
OK |
Java 8 |
TESTS |
6 |
171 |
14131200 |
|
|
163596755 |
Etheric_Wanderer |
D |
July 10, 2022, 7:50 p.m. |
OK |
Java 8 |
TESTS |
6 |
187 |
0 |
|
|
163610571 |
mariaskury |
D |
July 11, 2022, 1:41 a.m. |
OK |
JavaScript |
TESTS |
13 |
155 |
17305600 |
|
|
163586824 |
noisegain |
D |
July 10, 2022, 5:39 p.m. |
OK |
Kotlin 1.6 |
TESTS |
6 |
296 |
7884800 |
|
|
163608665 |
Mrs.zhou |
D |
July 11, 2022, 1:04 a.m. |
OK |
MS C++ 2017 |
TESTS |
13 |
46 |
204800 |
|
|
163598293 |
30SK5 |
D |
July 10, 2022, 8:19 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
46 |
614400 |
|
|
163621890 |
justdhs |
D |
July 11, 2022, 4:37 a.m. |
OK |
MS C++ 2017 |
TESTS |
13 |
46 |
1024000 |
|
|
163596641 |
KemPi |
D |
July 10, 2022, 7:48 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
46 |
5836800 |
|
|
163586300 |
Nosov_Vovanus2022 |
D |
July 10, 2022, 5:34 p.m. |
OK |
MS C++ 2017 |
TESTS |
6 |
296 |
614400 |
|
|
163592900 |
bpdolson |
D |
July 10, 2022, 6:50 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
218 |
8396800 |
|
|
163583356 |
racernigga |
D |
July 10, 2022, 5:11 p.m. |
OK |
PyPy 3 |
TESTS |
6 |
436 |
11059200 |
|
|
163594732 |
Rikudo_6 |
D |
July 10, 2022, 7:17 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
140 |
17920000 |
|
|
163594846 |
Rikudo_6 |
D |
July 10, 2022, 7:19 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
155 |
31641600 |
|
|
163619839 |
wwwwzhh |
D |
July 11, 2022, 4:03 a.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
186 |
150630400 |
|
|
163622544 |
shiviDON |
D |
July 11, 2022, 4:46 a.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
202 |
16896000 |
|
|
163588098 |
_N_0_0_B_ |
D |
July 10, 2022, 5:52 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
249 |
21811200 |
|
|
163618063 |
Youarenotgood |
D |
July 11, 2022, 3:37 a.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
326 |
10342400 |
|
|
163626495 |
iwillgo |
D |
July 11, 2022, 5:38 a.m. |
OK |
PyPy 3-64 |
TESTS |
13 |
342 |
28057600 |
|
|
163594455 |
kduggirala |
D |
July 10, 2022, 7:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
374 |
28262400 |
|
|
163593075 |
SophieHatter |
D |
July 10, 2022, 6:53 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
389 |
33484800 |
|
|
163583719 |
krishna369 |
D |
July 10, 2022, 5:13 p.m. |
OK |
PyPy 3-64 |
TESTS |
6 |
421 |
33996800 |
|
|
163588134 |
_N_0_0_B_ |
D |
July 10, 2022, 5:53 p.m. |
OK |
Python 3 |
TESTS |
6 |
155 |
2764800 |
|
|
163622662 |
MohamedHamed123 |
D |
July 11, 2022, 4:47 a.m. |
OK |
Python 3 |
TESTS |
13 |
171 |
921600 |
|
|
163627513 |
Lhohelhohehmm |
D |
July 11, 2022, 5:48 a.m. |
OK |
Python 3 |
TESTS |
13 |
202 |
7680000 |
|
|
163619069 |
ayush190 |
D |
July 11, 2022, 3:52 a.m. |
OK |
Python 3 |
TESTS |
13 |
233 |
1126400 |
|
|
163599350 |
abel_abate |
D |
July 10, 2022, 8:39 p.m. |
OK |
Python 3 |
TESTS |
13 |
233 |
2662400 |
|
|
163588288 |
pratyush155 |
D |
July 10, 2022, 5:54 p.m. |
OK |
Python 3 |
TESTS |
6 |
249 |
2662400 |
|
|
163596112 |
Arunava_392 |
D |
July 10, 2022, 7:39 p.m. |
OK |
Python 3 |
TESTS |
6 |
280 |
16793600 |
|
|
163588583 |
kauperwood |
D |
July 10, 2022, 5:57 p.m. |
OK |
Python 3 |
TESTS |
6 |
311 |
19456000 |
|
|
163625615 |
MohaSa |
D |
July 11, 2022, 5:27 a.m. |
OK |
Python 3 |
TESTS |
13 |
327 |
19763200 |
|
|
163586773 |
LOVGe |
D |
July 10, 2022, 5:39 p.m. |
OK |
Python 3 |
TESTS |
6 |
358 |
716800 |
|
|
163588537 |
yaaaa2k |
D |
July 10, 2022, 5:57 p.m. |
OK |
Ruby 3 |
TESTS |
6 |
436 |
921600 |
|
|
163583178 |
jakobrs |
D |
July 10, 2022, 5:09 p.m. |
OK |
Rust 2021 |
TESTS |
6 |
62 |
8704000 |
|
|
remove filters
Back to search problems