CT28655

Zigzag stretches Checker Stretch

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the mangrove channels of Rootwater opens only for a perfect tally of stretches. Tina 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 <= 1236; 0 <= a[i] <= 1000000.

Example 1:

Input: 1025 727973 633689 215713 842746 32959 89559 937093 192475 931159 375624 583445 39572 792989 348781 907701 584200 665529 516955 281946 347018 236950 414187 856918 527409 954615 745964 318525 667738 926429 446103 909151 750833 380272 163662 33200 538859 91302 992220 388219 161092 845878 520058 669460 643941 529514 830759 858008 723930 276355 674246 255185 331237 825009 855079 123034 608398 585324 538320 88342 356116 80730 510704 316069 1978 855167 965113 902884 493676 430664 232529 898505 803017 347003 520481 664215 247444 935682 155971 656126 133698 715781 426880 110453 243566 733611 686825 506366 204503 515907 372099 525909 15620 177676 226206 616193 243135 867199 117971 285873 750966 150741 53856 911653 976003 58603 685674 803367 556753 987249 429954 448016 413458 194327 119508 405650 34…
Output: 8

Example 2:

Input: 292 956272 880026 297035 919428 549225 222795 542082 343724 543980 441606 27553 311099 803242 184576 545717 366267 111144 203272 282321 785528 875024 541287 290266 751253 789258 585826 304628 917172 309928 110152 750790 326489 220427 118545 273726 435758 200689 822969 267210 428513 533574 309221 130043 108376 207325 705248 898286 912960 169172 843919 374529 549728 54961 213467 98685 714669 174821 673427 326713 686934 829483 541572 752521 120493 786694 883944 985823 49947 984154 559323 765912 775380 897877 174480 279990 685936 693648 159828 201226 482774 791428 92461 995683 904546 390527 924645 913870 278909 100050 945032 789864 2933 79601 792308 795522 582818 361848 789809 402957 555467 330398 660096 679511 494910 770629 332949 719316 114524 423754 852915 981095 58575 53164 329725 779939 7…
Output: 8

Example 3:

Input: 634 403945 268548 618823 329296 887826 875218 398985 70758 696884 989335 523536 623737 893829 651178 932757 557430 55665 696660 622496 841668 389935 479257 122397 977133 592535 778350 948039 90707 22786 966987 470935 961109 359373 496673 700042 726856 658009 55424 122250 817486 582306 190714 326939 115621 383519 163449 145948 610961 775838 197383 842327 427675 846524 269704 137287 615271 590645 436156 534506 583214 118382 334539 246918 132635 839413 331539 976716 201655 729578 417660 608193 854866 993536 45764 600552 837889 579102 446775 868243 216438 534173 867828 533354 966343 782043 395581 67621 805443 584541 150655 155633 66800 494734 913167 766953 912366 146134 754182 680714 336790 499111 458369 198888 548818 349730 807981 236020 679761 597218 297487 756482 636451 690806 819768 833112…
Output: 9

Constraints:

1 <= n <= 1236; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Zigzag stretches Checker Stretch - EASY Coding Problem | CodeTikki