CT57203

Nila's contracts Reckoning

MediumL6 · Pointer PhantomAcceptance: 0.0%XP: 100

Nila inherited the timber yard at the saffron fields of Marigold Row along with its curious bookkeeping system for contracts. Time to make sense of it. Task: n tasks of types 0..T must run with at least k idle/other tasks between two same-type tasks. Print the minimum total time including any needed idles. Input format: First line: n and k. Second line: n task types. Output format: Print the minimum completion time. Constraints: 1 <= n <= 4000; 0 <= k <= 100; 0 <= type < 1000.

Example 1:

Input: 3168 64 967 528 336 249 463 478 932 838 594 240 268 594 83 525 104 197 325 749 543 550 525 568 405 262 977 682 169 549 138 768 637 379 905 897 112 436 769 650 898 579 357 526 16 788 139 437 277 930 198 335 683 780 379 962 684 19 816 70 28 837 455 22 816 764 956 352 97 247 202 631 489 320 13 179 453 403 997 551 206 12 456 347 402 300 725 476 259 948 170 842 573 141 99 430 68 751 535 431 119 116 462 10 912 525 237 606 652 441 781 117 550 120 120 862 153 978 441 947 746 942 178 725 109 916 788 690 572 1 44 837 894 633 540 623 366 154 570 849 962 3 364 93 384 554 233 497 48 882 679 154 70 434 318 672 607 927 901 745 285 955 427 453 960 136 409 322 106 159 769 394 772 698 890 461 951 901 834 878 687 671 986 916 405 38 107 131 69 978 671 773 386 200 228 876 589 667 745 239 176 613 4 898 916 37 8…
Output: 3168

Example 2:

Input: 191 59 873 56 230 896 454 395 502 172 569 365 231 933 510 862 330 418 251 902 162 897 783 907 434 414 33 671 583 963 299 325 762 615 447 819 891 626 258 817 370 707 109 793 406 473 321 727 446 809 70 686 758 966 414 293 147 7 1 941 152 110 142 796 390 517 636 170 654 659 334 64 728 747 607 202 704 63 335 526 476 633 917 764 159 489 890 97 776 72 942 961 186 934 967 900 575 448 860 696 350 764 147 177 965 412 884 487 272 795 386 802 244 569 970 974 474 17 953 57 959 143 411 946 761 39 365 726 141 348 478 475 709 9 233 837 979 448 547 340 25 884 743 473 539 478 574 125 897 38 551 763 132 831 459 38 774 579 19 434 990 830 116 828 434 720 478 441 615 451 233 614 365 13 354 890 549 85 260 362 52 362 124 969 188 269 844 211 700 177 516 617 357
Output: 191

Example 3:

Input: 1829 9 801 282 170 900 972 426 822 539 418 976 565 381 750 66 854 651 874 654 506 248 354 560 614 174 230 763 812 600 379 441 473 331 703 418 553 930 385 19 239 13 403 660 745 255 551 216 124 981 458 787 392 80 738 86 674 552 455 912 30 731 735 222 879 206 394 232 434 809 327 764 631 877 33 61 752 231 787 787 403 876 850 476 742 213 424 648 856 478 887 191 800 590 895 364 619 319 896 654 986 661 431 606 581 377 514 654 202 566 944 751 774 209 309 205 229 315 321 520 55 379 738 590 885 143 519 11 345 174 580 613 840 869 71 75 945 282 959 744 96 995 898 854 506 84 496 207 41 623 802 147 822 879 116 221 594 516 316 737 100 136 601 632 630 218 289 880 714 918 231 274 490 548 476 386 365 286 829 971 501 320 563 814 106 686 828 113 63 722 344 550 835 739 393 596 122 804 440 422 51 323 446 610 59…
Output: 1829

Constraints:

1 <= n <= 4000; 0 <= k <= 100; 0 <= type < 1000.

Loading...
Test Cases:No test cases
No test cases available.