TheRealSamuel/LeetCodeProblem
0564
1{2 "id": 3442,3 "name": "maximum_total_reward_using_operations_i",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/maximum-total-reward-using-operations-i/",6 "date": "2024-06-02 00:00:00",7 "task_description": "You are given an integer array `rewardValues` of length `n`, representing the values of rewards. Initially, your total reward `x` is 0, and all indices are **unmarked**. You are allowed to perform the following operation **any** number of times: Choose an **unmarked** index `i` from the range `[0, n - 1]`. If `rewardValues[i]` is **greater** than your current total reward `x`, then add `rewardValues[i]` to `x` (i.e., `x = x + rewardValues[i]`), and **mark** the index `i`. Return an integer denoting the **maximum **_total reward_ you can collect by performing the operations optimally. **Example 1:** **Input:** rewardValues = [1,1,3,3] **Output:** 4 **Explanation:** During the operations, we can choose to mark the indices 0 and 2 in order, and the total reward will be 4, which is the maximum. **Example 2:** **Input:** rewardValues = [1,6,4,3,2] **Output:** 11 **Explanation:** Mark the indices 0, 2, and 1 in order. The total reward will then be 11, which is the maximum. **Constraints:** `1 <= rewardValues.length <= 2000` `1 <= rewardValues[i] <= 2000`",8 "public_test_cases": [9 {10 "label": "Example 1",11 "input": "rewardValues = [1,1,3,3]",12 "output": "4 "13 },14 {15 "label": "Example 2",16 "input": "rewardValues = [1,6,4,3,2]",17 "output": "11 "18 }19 ],20 "private_test_cases": [21 {22 "input": [23 1504,24 1885,25 575,26 826,27 985,28 211,29 1552,30 941,31 256,32 1617,33 530,34 306,35 654,36 1064,37 1121,38 1875,39 1958,40 134,41 825,42 1203,43 1874,44 1795,45 848,46 1534,47 1944,48 57,49 1415,50 255,51 1484,52 21,53 1375,54 1196,55 1969,56 259,57 809,58 205,59 345,60 1430,61 1090,62 1480,63 1004,64 9,65 1945,66 1379,67 831,68 1854,69 1418,70 789,71 33,72 1105,73 1455,74 207,75 291,76 1735,77 1831,78 1158,79 250,80 666,81 87,82 1741,83 108,84 126,85 1849,86 1097,87 629,88 525,89 635,90 623,91 1737,92 228,93 1259,94 991,95 1780,96 833,97 185,98 1648,99 1261,100 895,101 861,102 1607,103 203,104 1638,105 1116,106 417,107 1486,108 1622,109 703,110 1775,111 1020,112 1497,113 22,114 241,115 1108,116 1638,117 1656,118 1771,119 692,120 579,121 1395,122 1291,123 806,124 837,125 845,126 847,127 1938,128 638,129 809,130 1081,131 2000,132 1024,133 96,134 1751,135 651,136 1867,137 814,138 681,139 646,140 133,141 622,142 1164,143 1467,144 154,145 1386,146 1095,147 1963,148 1808,149 529,150 1526,151 511,152 1405,153 1806,154 249,155 1295,156 1816,157 185,158 1927,159 995,160 631,161 1215,162 1655,163 791,164 815,165 900,166 1077,167 1923,168 366,169 250,170 887,171 1571,172 1035,173 300,174 1050,175 581,176 1873,177 1079,178 1349,179 1981,180 1355,181 231,182 1515,183 275,184 1884,185 1393,186 163,187 1746,188 243,189 176,190 555,191 1134,192 876,193 71,194 1574,195 222,196 750,197 933,198 451,199 1230,200 171,201 428,202 59,203 765,204 506,205 1427,206 442,207 1168,208 1387,209 491,210 445,211 452,212 1527,213 1561,214 121,215 1281,216 1022,217 1715,218 349,219 202,220 620,221 513,222 1601,223 103,224 626,225 834,226 371,227 1978,228 286,229 589,230 353,231 1406,232 166,233 1838,234 1624,235 1467,236 1547,237 957,238 1898,239 295,240 1863,241 1471,242 1734,243 447,244 29,245 984,246 477,247 1748,248 651,249 835,250 1800,251 794,252 1816,253 444,254 758,255 202,256 1979,257 768,258 1674,259 1633,260 593,261 391,262 528,263 1518,264 1367,265 1286,266 832,267 1479,268 1682,269 136,270 786,271 1463,272 121,273 60,274 709,275 1151,276 53,277 1990,278 1843,279 1708,280 1595,281 1601,282 1966,283 1618,284 1192,285 747,286 747,287 1717,288 7,289 1546,290 750,291 1688,292 22,293 1712,294 679,295 394,296 1624,297 444,298 497,299 939,300 1569,301 1984,302 750,303 18,304 789,305 678,306 434,307 1430,308 646,309 60,310 1841,311 1095,312 1432,313 1009,314 537,315 28,316 432,317 431,318 809,319 1758,320 627,321 193,322 1909,323 1273,324 1333,325 1545,326 197,327 147,328 604,329 1196,330 1439,331 821,332 488,333 994,334 365,335 1915,336 1681,337 1837,338 1246,339 1088,340 780,341 883,342 1873,343 1494,344 138,345 678,346 1033,347 210,348 1903,349 199,350 1382,351 38,352 1594,353 1160,354 1912,355 733,356 1899,357 1346,358 1416,359 1726,360 971,361 123,362 928,363 1661,364 1066,365 1748,366 599,367 1922,368 273,369 45,370 819,371 5,372 124,373 751,374 1393,375 1054,376 1884,377 465,378 572,379 1791,380 1913,381 964,382 184,383 740,384 1420,385 319,386 491,387 394,388 1337,389 996,390 276,391 611,392 184,393 524,394 1309,395 528,396 1408,397 370,398 1459,399 782,400 292,401 252,402 1384,403 913,404 1572405 ],406 "output": 3999407 },408 {409 "input": [410 1016,411 642,412 410,413 1407,414 1134,415 492,416 1952,417 1603,418 1548,419 103,420 159,421 48,422 831,423 1373,424 504,425 401,426 53,427 1339,428 200,429 1743,430 1304,431 1054,432 1229,433 1664,434 1378,435 1052,436 1666,437 959,438 705,439 986,440 1120,441 19,442 332,443 459,444 438,445 1971,446 1504,447 415,448 1682,449 1451,450 457,451 1417,452 146,453 76,454 743,455 492,456 1992,457 1861,458 1302,459 1823,460 824,461 1839,462 755,463 484,464 621,465 372,466 628,467 860,468 1979,469 634,470 1326,471 1460,472 1212,473 1076,474 1188,475 490,476 802,477 1833,478 1584,479 1708,480 352,481 11,482 1787,483 706,484 903,485 1726,486 1468,487 1117,488 1500,489 1628,490 1837,491 1272,492 863,493 45,494 1876,495 24,496 1187,497 883,498 96,499 890,500 1572,501 170,502 510,503 575,504 870,505 1549,506 1807,507 175,508 1591,509 98,510 735,511 967,512 683,513 52,514 353,515 1581,516 1348,517 913,518 1340,519 602,520 328,521 1197,522 566,523 379,524 1397,525 1537,526 252,527 654,528 1520,529 632,530 31,531 1316,532 1573,533 752,534 1774,535 1227,536 1629,537 384,538 1338,539 591,540 118,541 1055,542 1087,543 490,544 1806,545 1392,546 1331,547 1332,548 1336,549 188,550 1902,551 1793,552 916,553 1221,554 1284,555 311,556 571,557 436,558 1752,559 890,560 747,561 1387,562 649,563 1331,564 1649,565 989,566 550,567 581,568 358,569 1807,570 982,571 784,572 1146,573 1508,574 240,575 1277,576 1743,577 1222,578 948,579 1594,580 24,581 468,582 1152,583 987,584 220,585 502,586 1275,587 886,588 847,589 1430,590 931,591 444,592 414,593 1910,594 1755,595 21,596 1969,597 1500,598 1423,599 343,600 1459,601 1790,602 433,603 82,604 574,605 483,606 1375,607 1546,608 991,609 927,610 1737,611 636,612 440,613 50,614 1442,615 1099,616 1125,617 336,618 1153,619 915,620 696,621 601,622 776623 ],624 "output": 3983625 },626 {627 "input": [628 641,629 1407,630 1254,631 1405,632 1431,633 861,634 794,635 1979,636 1981,637 858,638 1199,639 838,640 863,641 1423,642 1588,643 1235,644 219,645 223,646 26,647 241,648 498,649 1379,650 1287,651 18,652 1392,653 676,654 1230,655 510,656 1356,657 649,658 1373,659 1321,660 995,661 1888,662 580,663 438,664 254,665 1902,666 424,667 618,668 1685,669 951,670 96,671 619,672 90,673 19,674 906,675 1226,676 565,677 357,678 338,679 954,680 19,681 1920,682 940,683 107,684 691,685 1495,686 173,687 282,688 1968,689 1820,690 1607,691 1096,692 315,693 1271,694 1999,695 1315,696 352,697 895,698 275,699 1472,700 1665,701 1514,702 442,703 1940,704 297,705 1408,706 322,707 1321,708 805,709 1696,710 1137,711 1909,712 446,713 1142,714 1585,715 1316,716 463,717 1720,718 1218,719 844,720 636,721 476,722 925,723 933,724 1426,725 1811,726 1174,727 662,728 335,729 93,730 1367,731 1963,732 597,733 1581,734 1937,735 368,736 450,737 960,738 1535,739 787,740 478,741 675,742 575,743 1103,744 283,745 1151,746 661,747 1867,748 1638,749 728,750 1433,751 1971,752 80,753 1090,754 1927,755 45,756 1876,757 1332,758 1497,759 855,760 1325,761 1738,762 79,763 1314,764 1190,765 333,766 280,767 145,768 1422,769 1697,770 223,771 356,772 600,773 847,774 550,775 625,776 1028,777 714,778 926,779 256,780 1846,781 787,782 1692,783 936,784 1728,785 1660,786 1889,787 813,788 343,789 950,790 107,791 1023,792 407,793 1386,794 281,795 1214,796 959,797 1116,798 1926,799 582,800 45,801 211,802 1331,803 1097,804 1260,805 955,806 1331,807 1079,808 329,809 1402,810 1941,811 1320,812 544,813 873,814 1282,815 929,816 1445,817 1740,818 475,819 1248,820 410,821 225,822 483,823 1511,824 1274,825 1129,826 569,827 1652,828 763,829 1180,830 1099,831 1164,832 1018,833 1415,834 1053,835 1978,836 624,837 144,838 395,839 500,840 396,841 1335,842 1642,843 149,844 186,845 981,846 767,847 188,848 272,849 82,850 953,851 389,852 293,853 122,854 998,855 1380,856 158,857 1173,858 866,859 1850,860 225,861 400,862 1470,863 908,864 1949,865 264,866 1146,867 530,868 251,869 1109,870 1981,871 179,872 1549,873 616,874 666,875 955,876 719,877 1774,878 1989,879 84,880 921,881 1646,882 37,883 1264,884 1035,885 966,886 17,887 1806,888 1306,889 1594,890 1336,891 1267,892 171,893 1761,894 1684,895 788,896 1507,897 1771,898 194,899 1929,900 837,901 822,902 1191,903 1009,904 1654,905 1299,906 257,907 1879,908 507,909 924,910 1605,911 1464,912 115,913 1585,914 357,915 459,916 1370,917 1314,918 1719,919 1333,920 1908,921 1233,922 1250,923 1006,924 1330,925 24,926 1377,927 816,928 1299,929 546,930 1961,931 104,932 787,933 748,934 682,935 91,936 1082,937 988,938 672,939 1271,940 1530,941 1463,942 962,943 526,944 947,945 1402,946 1428,947 1962,948 1890,949 310,950 1636,951 1647,952 1446,953 879,954 597,955 519,956 514,957 1014,958 1104,959 1422,960 377,961 111,962 1212,963 177,964 528,965 892,966 83,967 915,968 1079,969 1633,970 1975,971 1818,972 40,973 765,974 1796,975 1422,976 1642,977 1585,978 1861,979 200,980 790,981 1826,982 335,983 1959,984 851,985 885,986 263,987 722,988 1415,989 504,990 535,991 1453,992 975,993 1803,994 1371,995 118,996 1497,997 837,998 1146,999 1163,1000 1177,1001 562,1002 118,1003 1512,1004 576,1005 1490,1006 900,1007 457,1008 1702,1009 1724,1010 190,1011 1359,1012 547,1013 1518,1014 13,1015 1468,1016 1342,1017 992,1018 1093,1019 1536,1020 616,1021 1761,1022 680,1023 1157,1024 365,1025 1695,1026 1629,1027 720,1028 1132,1029 1728,1030 1104,1031 595,1032 1624,1033 1879,1034 37,1035 1591,1036 377,1037 680,1038 1458,1039 1096,1040 103,1041 1215,1042 470,1043 249,1044 259,1045 764,1046 977,1047 1102,1048 1728,1049 1022,1050 1490,1051 984,1052 1488,1053 1550,1054 1688,1055 228,1056 628,1057 1490,1058 707,1059 285,1060 1213,1061 1104,1062 60,1063 924,1064 94,1065 1637,1066 1262,1067 1995,1068 654,1069 944,1070 668,1071 1912,1072 1271,1073 191,1074 143,1075 1161,1076 562,1077 421,1078 659,1079 1897,1080 1293,1081 1305,1082 407,1083 1493,1084 1499,1085 214,1086 1078,1087 776,1088 213,1089 1950,1090 1618,1091 196,1092 1971,1093 1331,1094 733,1095 1363,1096 1298,1097 315,1098 1034,1099 737,1100 498,1101 597,1102 1962,1103 1706,1104 1761,1105 674,1106 1693,1107 1268,1108 1764,1109 351,1110 1736,1111 1735,1112 497,1113 1185,1114 572,1115 1929,1116 575,1117 1223,1118 1418,1119 845,1120 1453,1121 466,1122 839,1123 1604,1124 486,1125 1476,1126 1283,1127 847,1128 1762,1129 1758,1130 1595,1131 962,1132 347,1133 1447,1134 962,1135 509,1136 106,1137 175,1138 1311,1139 1251,1140 416,1141 958,1142 108,1143 1264,1144 1394,1145 1867,1146 1147,1147 1907,1148 237,1149 1400,1150 1401,1151 1606,1152 1660,1153 991,1154 1526,1155 1012,1156 261,1157 579,1158 1654,1159 1262,1160 1617,1161 96,1162 820,1163 734,1164 1545,1165 444,1166 1695,1167 849,1168 1402,1169 280,1170 46,1171 426,1172 1298,1173 1527,1174 593,1175 965,1176 192,1177 860,1178 501,1179 1713,1180 70,1181 1054,1182 1289,1183 1689,1184 1174,1185 1506,1186 1615,1187 603,1188 197,1189 1373,1190 1277,1191 1466,1192 635,1193 313,1194 446,1195 1501,1196 1423,1197 1998,1198 1480,1199 1669,1200 1647,