CT31840

Hope's stretches Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the indigo vats of Bluehollow opens only for a perfect tally of stretches. Hope means to find out. Task: Print the length of the longest contiguous run in which elements alternate even, odd, even, odd, ... Input format: First line: n. Second line: n integers. Output format: Print the maximum parity-alternating run length. Constraints: 1 <= n <= 1275; 0 <= a[i] <= 1000.

Example 1:

Input: 519 482 444 7 406 984 407 164 639 341 111 650 749 160 620 90 855 354 925 308 424 769 254 337 941 511 377 460 858 281 931 479 821 184 560 144 419 130 386 870 614 734 274 992 503 766 317 668 265 1 774 874 34 163 450 277 105 883 525 704 124 5 616 534 886 630 301 239 284 522 983 848 4 89 11 900 137 210 388 495 141 297 480 915 241 989 738 66 351 740 612 318 439 115 962 727 673 69 999 716 493 763 3 414 772 757 520 758 455 821 96 908 14 47 994 436 916 581 847 177 234 342 39 664 674 292 361 649 840 220 59 405 914 453 790 912 602 493 140 329 162 606 575 418 377 925 229 989 770 811 951 496 314 770 936 7 115 220 472 520 663 656 572 973 358 933 572 362 435 287 11 328 458 425 65 995 594 729 565 901 997 0 61 626 310 879 79 396 602 14 763 172 977 970 40 70 993 249 369 852 237 424 725 670 218 761 194 654 …
Output: 6

Example 2:

Input: 694 584 988 703 572 299 219 107 632 632 76 187 544 340 435 264 583 25 31 974 714 104 417 233 39 830 376 552 415 959 102 484 637 15 172 624 769 903 444 477 681 843 440 789 684 207 75 527 894 734 707 346 951 842 736 125 907 134 254 130 85 572 730 518 736 383 415 929 93 497 126 787 949 572 683 661 378 491 931 305 540 267 955 896 165 967 934 202 525 648 215 480 852 589 366 725 645 414 166 923 865 946 228 720 273 980 983 333 55 638 717 908 538 389 461 405 226 514 299 791 34 129 727 970 221 736 633 437 789 252 725 204 238 444 973 113 192 965 768 537 280 692 937 834 114 168 37 241 174 839 227 840 407 891 878 649 574 462 358 26 314 708 80 568 746 74 788 679 896 121 224 756 904 510 573 977 53 886 141 440 685 218 929 839 526 166 709 403 190 819 210 696 357 742 267 324 448 54 315 313 47 887 450 506 6…
Output: 11

Example 3:

Input: 862 936 732 341 793 34 553 783 479 782 271 921 351 676 121 786 790 485 386 225 79 839 498 194 110 937 452 298 911 304 660 240 443 956 965 684 433 977 304 341 173 752 586 523 24 343 686 16 132 468 475 938 270 89 856 717 871 756 144 942 475 695 479 36 31 490 703 289 631 660 295 940 752 180 56 257 822 74 267 859 627 961 932 8 349 46 51 434 724 421 635 2 60 464 858 128 927 356 939 732 164 548 255 869 588 431 545 534 427 811 970 782 944 176 123 621 675 197 809 239 879 87 370 416 858 292 504 795 32 796 248 688 538 280 8 588 395 605 284 498 125 974 8 397 593 822 795 238 874 102 845 611 271 476 673 669 394 632 720 75 604 143 457 385 254 654 37 689 275 694 88 526 804 639 75 474 280 714 386 994 405 936 413 411 324 368 37 916 447 32 916 973 962 969 626 535 120 197 181 853 25 98 442 420 155 940 33 737…
Output: 10

Constraints:

1 <= n <= 1275; 0 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
Hope's stretches Reckoning - MEDIUM Coding Problem | CodeTikki