CT30432

The vials Longest Chain Puzzle

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The ledger master Fiora has been asked to publish the quarterly findings. On the desk lies a long table of vials readings. Task: Print the length of the longest run of consecutive integers present in the array (e.g. 4,5,6 counts as 3). Input format: First line: n. Second line: n integers. Output format: Print the longest consecutive run length. Constraints: 1 <= n <= 14097; 0 <= a[i],x <= 1000.

Example 1:

Input: 727 622 988 646 812 310 858 480 42 318 797 910 32 52 848 593 344 478 387 114 632 795 842 320 693 872 626 478 474 749 286 377 342 102 426 763 532 862 195 641 846 733 578 856 848 603 370 601 28 434 138 637 109 539 266 52 911 597 203 870 240 404 374 932 103 756 695 538 628 891 783 847 737 571 685 664 653 767 701 870 682 301 691 168 800 331 557 419 44 908 774 938 952 324 764 290 780 665 145 519 656 14 410 447 341 682 235 747 748 393 780 835 132 371 538 514 950 256 740 436 577 989 611 190 703 838 188 50 600 375 595 690 723 901 186 196 813 53 249 529 753 76 432 170 339 462 93 760 235 462 984 703 213 2 202 49 196 58 134 121 863 419 250 574 370 728 711 740 379 531 970 526 857 952 925 63 417 788 970 85 446 464 617 43 905 979 915 757 418 71 215 87 356 651 236 3 896 497 445 766 173 261 963 652 771 30…
Output: 8

Example 2:

Input: 2798 941 410 694 852 827 441 33 686 337 730 477 413 908 89 24 790 196 89 936 586 785 492 523 909 921 391 592 925 529 376 825 476 470 532 764 41 769 787 302 59 586 152 153 555 703 433 531 57 324 911 39 582 552 734 547 95 149 838 965 178 620 449 84 528 659 397 991 888 470 82 725 242 509 413 267 316 764 601 451 651 882 112 346 988 728 969 495 198 915 623 725 30 560 260 716 466 470 41 104 519 903 73 401 33 713 343 919 130 758 13 539 361 323 917 599 802 109 867 380 761 747 263 34 763 578 765 363 930 484 661 25 151 187 899 63 650 52 597 570 746 439 553 310 371 65 240 770 199 75 688 73 576 871 271 248 284 974 881 935 208 34 74 605 316 717 99 992 427 983 986 215 408 333 428 87 352 986 245 958 376 54 858 945 331 513 248 503 978 229 473 550 307 874 822 501 446 709 312 75 721 926 51 564 255 20 640 88…
Output: 80

Example 3:

Input: 3571 576 251 118 738 777 617 493 544 685 539 718 876 873 718 588 12 938 284 87 886 832 453 896 688 679 525 848 386 232 239 358 859 89 41 162 417 38 387 894 602 447 833 45 768 884 805 865 463 357 411 805 698 610 511 915 379 951 756 241 768 137 920 334 772 93 809 883 816 767 141 782 850 627 304 958 28 607 172 310 151 954 84 611 144 455 327 893 210 584 520 763 55 153 486 986 487 47 925 257 830 790 195 743 220 937 593 956 212 285 602 686 476 795 871 349 307 618 661 841 82 650 627 87 420 755 664 231 917 835 884 283 188 95 75 65 217 683 236 907 896 880 781 271 848 349 102 207 787 107 371 196 907 15 32 134 78 733 476 212 662 994 457 406 689 868 170 799 387 431 834 424 336 506 942 851 174 649 410 410 231 281 481 861 519 10 546 778 307 585 183 16 291 61 743 880 320 776 749 621 103 371 126 95 451 99…
Output: 157

Constraints:

1 <= n <= 14097; 0 <= a[i],x <= 1000.

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