FPEvalDataset/LeetCodeProblem
0305
1{2 "id": 2469,3 "name": "longest_subsequence_with_limited_sum",4 "difficulty": "Easy",5 "link": "https://leetcode.com/problems/longest-subsequence-with-limited-sum/",6 "date": "1661040000000",7 "task_description": "You are given an integer array `nums` of length `n`, and an integer array `queries` of length `m`. Return _an array _`answer`_ of length _`m`_ where _`answer[i]`_ is the **maximum** size of a **subsequence** that you can take from _`nums`_ such that the **sum** of its elements is less than or equal to _`queries[i]`. A **subsequence** is an array that can be derived from another array by deleting some or no elements without changing the order of the remaining elements. **Example 1:** ``` **Input:** nums = [4,5,2,1], queries = [3,10,21] **Output:** [2,3,4] **Explanation:** We answer the queries as follows: - The subsequence [2,1] has a sum less than or equal to 3. It can be proven that 2 is the maximum size of such a subsequence, so answer[0] = 2. - The subsequence [4,5,1] has a sum less than or equal to 10. It can be proven that 3 is the maximum size of such a subsequence, so answer[1] = 3. - The subsequence [4,5,2,1] has a sum less than or equal to 21. It can be proven that 4 is the maximum size of such a subsequence, so answer[2] = 4. ``` **Example 2:** ``` **Input:** nums = [2,3,4,5], queries = [1] **Output:** [0] **Explanation:** The empty subsequence is the only subsequence that has a sum less than or equal to 1, so answer[0] = 0. ``` **Constraints:** `n == nums.length` `m == queries.length` `1 <= n, m <= 1000` `1 <= nums[i], queries[i] <= 106`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "nums = [4,5,2,1], queries = [3,10,21]",12 "output": "[2,3,4] "13 },14 {15 "label": "Example 2",16 "input": "nums = [2,3,4,5], queries = [1]",17 "output": "[0] "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 [24 823,25 3612,26 9943,27 17944,28 26590,29 36017,30 45991,31 57035,32 69635,33 83486,34 98036,35 115778,36 134339,37 156262,38 178658,39 209196,40 253708,41 305332,42 357321,43 412171,44 472589,45 538052,46 603521,47 669720,48 737935,49 810375,50 884429,51 959703,52 1038794,53 1125431,54 1214818,55 1304843,56 1397673,57 1494526,58 1595142,59 1696063,60 1798325,61 1906362,62 2020008,63 2134056,64 2254772,65 2376841,66 2498974,67 2621156,68 2744902,69 2870273,70 2998469,71 3128450,72 3260597,73 3400463,74 3544551,75 3690986,76 3838970,77 3990807,78 4143738,79 4298771,80 4461022,81 4623695,82 4787580,83 4964563,84 5143032,85 5327174,86 5515263,87 5709070,88 5904471,89 6100139,90 6308634,91 6520802,92 6733273,93 6949651,94 7169563,95 7408873,96 7649839,97 7891105,98 8134704,99 8378800,100 8628293,101 8885051,102 9155838,103 9429673,104 9703842,105 9978762,106 10260397,107 10560542,108 10861497,109 11164886,110 11470797,111 11786668,112 12103717,113 12421048,114 12740164,115 13061687,116 13388895,117 13722063,118 14059453,119 14403386,120 14750768,121 15100131,122 15463133,123 15828956,124 16194801,125 16562496,126 16935529,127 17311368,128 17696415,129 18081737,130 18470515,131 18859793,132 19249308,133 19638884,134 20029213,135 20424971,136 20825528,137 21229915,138 21635452,139 22041213,140 22448121,141 22857809,142 23268984,143 23681577,144 24095241,145 24512110,146 24932729,147 25355356,148 25781047,149 26207283,150 26641555,151 27076695,152 27512914,153 27949484,154 28390580,155 28835639,156 29284136,157 29733109,158 30191990,159 30660655,160 31129995,161 31600973,162 32078980,163 32566130,164 33053648,165 33547170,166 34047844,167 34550553,168 35055196,169 35562051,170 36085821,171 36610293,172 37136811,173 37665401,174 38195042,175 38729894,176 39267430,177 39811866,178 40358897,179 40908494,180 41458386,181 42009044,182 42570902,183 43144783,184 43726730,185 44311586,186 44904597,187 45497614,188 46098197,189 46700034,190 47304049,191 47912965,192 48525446,193 49138312,194 49751850,195 50370828,196 50990704,197 51613876,198 52239530,199 52866439,200 53495149,201 54125077,202 54757695,203 55390957,204 56025304,205 56661841,206 57303980,207 57959084,208 58614469,209 59276074,210 59940407,211 60605543,212 61274691,213 61945714,214 62617323,215 63289793,216 63964394,217 64649748,218 65338023,219 66028840,220 66723816,221 67421654,222 68119584,223 68817919,224 69516892,225 70218006,226 70919838,227 71626428,228 72333550,229 73047007,230 73761027,231 74482527,232 75207806,233 75935414,234 76664518,235 77409142,236 78160992,237 78915313,238 79672148,239 80438543,240 81211099,241 81990352,242 82771111,243 83557853,244 84349964,245 85148137,246 85950734,247 86755485,248 87561141,249 88368200,250 89176573,251 89985465,252 90805341,253 91625803,254 92447824,255 93271095,256 94096188,257 94924132,258 95753987,259 96589555,260 97426854,261 98264903,262 99110168,263 99957386,264 100819745,265 101686493,266 102561284,267 103438819,268 104320448,269 105202724,270 106091252,271 106988261,272 107888345,273 108788927,274 109691532,275 110597845,276 111504383,277 112417228,278 113332215,279 114250954,280 115174444,281 116102192,282 117034844,283 117972619,284 118912041,285 119853660,286 120797831,287 121743755,288 122691699,289 123640762,290 124590858,291 125543026,292 126496128,293 127451552,294 128410147,295 129370905,296 130336332,297 131303129,298 132273137,299 133244905,300 134217073,301 135192914,302 136170616,303 137149531,304 138129722,305 139110177,306 140091562,307 141076174,308 142062740,309 143054590,310 144049062,311 145049030312 ],313 [314 366220,315 52694,316 980904,317 888183,318 360671,319 407026,320 819786,321 101108,322 94607,323 948205,324 44868,325 991638,326 804050,327 402856,328 670274,329 120629,330 867219,331 248256,332 676156,333 445420,334 247337,335 422243,336 111030,337 993098,338 179336,339 812634,340 875997,341 629632,342 581054,343 794988,344 595270,345 368372,346 242966,347 132704,348 160715,349 128984,350 468513,351 207484,352 48995,353 232555,354 657882,355 895679,356 955136,357 524494,358 736947,359 498411,360 162034,361 214113,362 220160,363 698916,364 337488,365 63640,366 404721,367 296967,368 437261,369 805551,370 532038,371 733137,372 194329,373 678700,374 38627,375 664866,376 531276,377 274930,378 421848,379 276411,380 784719,381 31822,382 227470,383 655679,384 113763,385 630818,386 215214,387 454520,388 488401,389 763853,390 289020,391 531789,392 822726,393 753953,394 814456,395 734343,396 959881,397 800948,398 917530,399 437846,400 931103,401 976416,402 244780,403 471232,404 280687,405 237579,406 347571,407 879208,408 761129,409 546801,410 590834,411 779420,412 562546,413 99306,414 350612,415 372802,416 16196,417 573403,418 22182,419 422183,420 143751,421 989074,422 495525,423 123701,424 584981,425 880423,426 820138,427 92528,428 708560,429 244115,430 502264,431 556513,432 489536,433 264415,434 492834,435 194598,436 853180,437 67055,438 231027,439 870873,440 438092,441 40562,442 958556,443 217003,444 56049,445 572853,446 645674,447 234254,448 514508,449 767246,450 685720,451 544948,452 207527,453 437519,454 550171,455 55616,456 98895,457 706722,458 283629,459 941360,460 855362,461 941629,462 680049,463 620660,464 61127,465 233426,466 629260,467 622967,468 294098,469 712803,470 214681,471 941295,472 988266,473 264916,474 499870,475 468029,476 802240,477 47146,478 22969,479 486680,480 515257,481 478352,482 578644,483 287920,484 516263,485 875074,486 516566,487 853118,488 183020,489 877575,490 851261,491 88379,492 523338,493 210919,494 689269,495 23839,496 352137,497 319961,498 765846,499 673208,500 246853,501 628553,502 870244,503 134939,504 734521,505 986913,506 925646,507 931018,508 83823,509 494431,510 908990,511 414277,512 102349,513 833567,514 714131,515 454438,516 479181,517 761079,518 160237,519 674608,520 518543,521 235661,522 338978,523 70152,524 763396,525 819970,526 186226,527 249238,528 199819,529 513417,530 584716,531 181398,532 638409,533 245155,534 40261,535 122479,536 490288,537 569741,538 997900,539 8398,540 240996,541 39038,542 811029,543 401824,544 683528,545 727072,546 15964,547 537745,548 213048,549 218784,550 842241,551 547914,552 75607,553 7153,554 607984,555 716611,556 616160,557 811440,558 633608,559 397253,560 741776,561 458911,562 902864,563 289896,564 649378,565 279286,566 846566,567 734562,568 37376,569 287685,570 187646,571 856586,572 364819,573 808460,574 463500,575 332547,576 293551,577 655615,578 193782,579 291241,580 415871,581 663834,582 248850,583 256042,584 718476,585 69060,586 646059,587 596803,588 49049,589 76468,590 739842,591 453552,592 35992,593 519074,594 259863,595 246481,596 322412,597 135116,598 928373,599 66818,600 237745,601 851292,602 953765,603 617582,604 282624,605 456356,606 601059,607 825720,608 236945,609 256105,610 767361,611 110788,612 648761,613 224534,614 512171,615 873873,616 756972,617 498267,618 889852,619 422748,620 576351,621 384753,622 598647,623 40197,624 215375,625 892249,626 457779,627 268020,628 724094,629 598409,630 956835,631 797739,632 307488,633 327323,634 67227,635 947678,636 567739,637 855395,638 621737,639 380775,640 572316,641 74395,642 303554,643 837627,644 215482,645 9978,646 50163,647 691874,648 401514,649 531374,650 669450,651 993,652 300590,653 413378,654 198111,655 144615,656 377176,657 947559,658 143580,659 985848,660 681168,661 440567,662 372596,663 874008,664 168814,665 989206,666 754102,667 403482,668 599367,669 665395,670 341944,671 288364,672 480881,673 971365,674 541801,675 634474,676 579988,677 36249,678 55407,679 121543,680 368894,681 335789,682 265635,683 138623,684 159353,685 99802,686 527997,687 862488,688 146017,689 648074,690 889855,691 204992,692 90978,693 767709,694 598882,695 101975,696 138756,697 576193,698 206221,699 485175,700 466412,701 230596,702 414379,703 937006,704 350289,705 669134,706 931926,707 542535,708 419331,709 366730,710 867724,711 125652,712 17729,713 262569,714 942521,715 831108,716 742682,717 152818,718 161562,719 870253,720 534170,721 62906,722 226064,723 72770,724 719300,725 545611,726 377710,727 198526,728 251996,729 721963,730 351642,731 697404,732 959747,733 99425,734 37195,735 7327,736 565362,737 181934,738 809627,739 561575,740 668502,741 657051,742 868588,743 446603,744 797671,745 403529,746 388380,747 600408,748 971594,749 577489,750 326649,751 318036,752 178220,753 912010,754 709882,755 806257,756 771184,757 648976,758 334393,759 311791,760 207313,761 530148,762 655621,763 231887,764 338884,765 770923,766 435396,767 526911,768 100184,769 503106,770 742220,771 747091,772 383115,773 107383,774 831586,775 380978,776 655364,777 426057,778 517479,779 168655,780 285638,781 763239,782 100699,783 178369,784 374688,785 631466,786 714818,787 632992,788 818882,789 887845,790 409908,791 308726,792 345725,793 818354,794 124133,795 591995,796 714637,797 717987,798 698400,799 25178,800 818106,801 199517,802 644832,803 238205,804 274077,805 830528,806 191203,807 898711,808 962279,809 611643,810 435447,811 444755,812 311517,813 21561,814 857673,815 147981,816 213492,817 46863,818 197535,819 735068,820 860957,821 99229,822 453135,823 413756,824 153999,825 33776,826 63828,827 628170,828 238330,829 18437,830 266479,831 389984,832 917398,833 47619,834 121316,835 383442,836 800917,837 657242,838 710308,839 523517,840 939156,841 669896,842 798113,843 912333,844 876481,845 210881,846 292907,847 547891,848 482117,849 255719,850 996245,851 198627,852 641133,853 337686,854 236867,855 323767,856 762690,857 785278,858 294146,859 216710,860 414887,861 92514,862 320448,863 126200,864 651396,865 196796,866 684434,867 149272,868 656435,869 491887,870 334323,871 661185,872 999487,873 281160,874 636076,875 855094,876 120840,877 743458,878 886294,879 838170,880 876375,881 299846,882 249647,883 394375,884 436037,885 261508,886 397143,887 811914,888 877990,889 302047,890 658144,891 888297,892 443779,893 504350,894 574878,895 42882,896 395542,897 284332,898 563563,899 128817,900 742415,901 986125,902 204046,903 80529,904 618452,905 284079,906 305694,907 860545,908 67675,909 370617,910 325294,911 274575,912 379170,913 991032,914 496142,915 924082,916 226922,917 818816,918 633822,919 266965,920 301141,921 541913,922 938499,923 70475,924 176728,925 104601,926 329439,927 982807,928 332876,929 982237,930 271995,931 879869,932 267660,933 647633,934 560105,935 755618,936 451284,937 838311,938 676987,939 38659,940 50875,941 546910,942 744983,943 263454,944 268978,945 491710,946 434252,947 25156,948 1248,949 912752,950 294988,951 803960,952 881918,953 618545,954 971735,955 387751,956 150524,957 713877,958 755991,959 312688,960 505470,961 33318,962 38141,963 499606,964 218291,965 988241,966 286699,967 438688,968 623699,969 965221,970 3183,971 821056,972 543473,973 539021,974 755421,975 520320,976 112410,977 620084,978 797054,979 792363,980 124504,981 144357,982 998070,983 483819,984 370703,985 562622,986 482918,987 16474,988 536725,989 555284,990 630094,991 834252,992 759665,993 653361,994 961950,995 74903,996 417730,997 987357,998 51762,999 495283,1000 723847,1001 477857,1002 986005,1003 376136,1004 390164,1005 241374,1006 917722,1007 375926,1008 608907,1009 101951,1010 782583,1011 282232,1012 197786,1013 381183,1014 202315,1015 981895,1016 489270,1017 839867,1018 859145,1019 768187,1020 947555,1021 995178,1022 734785,1023 122572,1024 218633,1025 857856,1026 342715,1027 48816,1028 733159,1029 375159,1030 504589,1031 998996,1032 982066,1033 223172,1034 295196,1035 826629,1036 792853,1037 766861,1038 15890,1039 496842,1040 91810,1041 310546,1042 768666,1043 363165,1044 760430,1045 954709,1046 338175,1047 141961,1048 985809,1049 184416,1050 990203,1051 47799,1052 492880,1053 862317,1054 451868,1055 819354,1056 437501,1057 85260,1058 660332,1059 233414,1060 750575,1061 735896,1062 504545,1063 120461,1064 979067,1065 497620,1066 431034,1067 819769,1068 531366,1069 901354,1070 172615,1071 458775,1072 161843,1073 811418,1074 857425,1075 169749,1076 704496,1077 305207,1078 400223,1079 597372,1080 601595,1081 688417,1082 927482,1083 236673,1084 667828,1085 377510,1086 412800,1087 363667,1088 644975,1089 304061,1090 477129,1091 852629,1092 588239,1093 600041,1094 699799,1095 278911,1096 805351,1097 726673,1098 245553,1099 889134,1100 83296,1101 121360,1102 629687,1103 202240,1104 211588,1105 70689,1106 185201,1107 579569,1108 232211,1109 29619,1110 840962,1111 878182,1112 576324,1113 52223,1114 437458,1115 640002,1116 74353,1117 687003,1118 190658,1119 836877,1120 156274,1121 88286,1122 306492,1123 77445,1124 727017,1125 316066,1126 575056,1127 215043,1128 769817,1129 348187,1130 247329,1131 655392,1132 344462,1133 7002,1134 839576,1135 661762,1136 539875,1137 309378,1138 230966,1139 990198,1140 977782,1141 878695,1142 327346,1143 510742,1144 484520,1145 266966,1146 796935,1147 249894,1148 19786,1149 295000,1150 46510,1151 51596,1152 421520,1153 523856,1154 827825,1155 576155,1156 394215,1157 833299,1158 254479,1159 236559,1160 984566,1161 32714,1162 965905,1163 315315,1164 73880,1165 524105,1166 705724,1167 887791,1168 454732,1169 170569,1170 610982,1171 282954,1172 623963,1173 107122,1174 913353,1175 799934,1176 71423,1177 850850,1178 587225,1179 169999,1180 174809,1181 742933,1182 412634,1183 122477,1184 466019,1185 480253,1186 783946,1187 762762,1188 328100,1189 931037,1190 509311,1191 532380,1192 4253,1193 878648,1194 232782,1195 499140,1196 657143,1197 790435,1198 792942,1199 615915,1200 977965,