CT29186

The Ruby stretches of Wren

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the boar woods of Tuskmore close for winter, Wren must finish the stretches ledger - one figure at a time. 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 <= 1994; 0 <= a[i] <= 1000.

Example 1:

Input: 511 897 987 218 754 52 829 877 492 198 457 592 219 108 961 584 264 274 3 485 586 351 485 51 230 772 125 475 446 732 823 755 70 793 751 155 757 257 687 976 778 874 392 478 832 609 400 186 476 184 544 640 33 726 667 450 451 561 678 869 612 262 57 44 319 594 176 498 235 717 251 924 51 939 271 927 141 915 945 616 973 791 790 512 711 719 769 156 530 619 561 38 85 733 838 186 48 427 717 253 201 724 434 644 979 692 333 975 718 658 954 854 693 752 904 359 87 91 629 290 452 647 5 482 930 978 754 341 619 786 818 146 274 732 260 798 485 818 83 187 430 453 466 519 263 573 546 942 440 806 361 988 759 175 912 758 889 426 559 48 911 283 856 315 442 347 236 20 370 411 987 193 296 823 921 43 684 71 991 231 589 773 59 877 215 756 242 10 675 505 183 911 49 736 248 557 259 666 244 730 132 37 780 203 890 412 7…
Output: 9

Example 2:

Input: 1066 822 688 305 126 713 233 671 262 638 558 494 799 493 670 903 7 647 453 132 900 602 354 13 52 746 695 222 715 945 496 535 703 498 413 545 525 532 558 206 962 425 943 261 608 169 690 638 313 880 395 615 66 580 378 782 132 99 214 534 277 596 918 744 610 861 528 620 655 294 224 30 241 414 638 174 491 164 58 395 889 904 935 756 825 378 620 706 98 711 330 963 339 141 417 277 416 852 148 642 193 77 557 570 287 216 110 856 154 886 454 555 133 536 628 898 951 938 94 106 859 951 750 855 372 86 959 839 476 320 203 485 912 895 977 771 956 895 520 352 286 710 496 468 47 42 184 57 267 209 795 206 675 656 60 226 195 578 10 545 353 159 385 389 578 146 669 568 184 556 850 481 64 441 119 35 799 398 672 940 919 735 675 39 592 178 466 849 720 503 150 868 69 17 981 68 884 342 160 248 806 29 102 599 356 107…
Output: 13

Example 3:

Input: 439 472 373 896 219 766 29 353 250 467 594 270 875 854 130 980 525 399 50 267 380 878 495 498 360 726 150 605 24 998 586 812 693 116 170 811 140 917 633 211 221 409 904 804 592 426 707 204 293 486 192 298 157 454 331 645 545 442 258 417 341 377 866 6 395 50 863 335 304 668 862 518 33 103 924 88 323 333 213 263 16 684 151 128 97 656 542 632 578 741 111 624 649 620 260 36 183 119 285 112 471 268 215 419 767 462 815 40 207 607 211 463 915 949 51 41 237 626 914 375 970 566 531 710 940 798 462 832 557 297 788 988 32 412 699 412 586 947 258 903 601 489 362 820 838 956 531 868 549 610 377 696 194 976 847 672 757 158 455 357 82 333 499 508 650 195 954 742 940 611 707 718 972 348 984 636 598 667 821 816 185 174 561 557 595 549 820 387 448 176 509 131 516 136 130 520 370 5 348 983 323 242 651 94 684…
Output: 7

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Ruby stretches of Wren - MEDIUM Coding Problem | CodeTikki