CT29100

Clerk's stretches Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Caravans arrive at the seal rocks of Barking Cove with crates of stretches, and Clerk the inventory keeper must account for every last one. 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 <= 2369; 0 <= a[i] <= 1000000.

Example 1:

Input: 503 715226 166742 732947 878978 187588 252064 393818 805444 853673 417883 127522 800158 406297 904971 849630 987047 649228 951839 465742 595051 766787 551767 86425 659588 52635 159012 471683 859814 706399 425097 632904 17042 762342 585860 249926 810630 510293 160578 265640 707776 443181 861427 285105 389654 212343 555859 270940 263320 730159 825213 3255 26367 946146 514148 378818 970605 298328 451633 997265 517517 450253 791721 87437 290483 317193 480464 968958 26925 173789 895887 797249 641132 747225 228211 824023 101381 697007 166608 208921 123338 432145 604472 171574 741746 693062 871009 360973 229570 25611 807114 389175 942128 117889 204763 987750 25563 788079 569677 133940 791861 960590 503352 375491 241109 493225 47097 311883 132219 367548 164747 56413 470305 731664 318869 570395 529…
Output: 7

Example 2:

Input: 32 67888 459896 998412 725132 964774 822645 56461 850298 373702 125665 922357 362164 914466 313121 467545 175473 105427 744528 429139 903669 972965 618807 801627 595178 616641 636693 605490 206355 941196 199711 539742 966600
Output: 6

Example 3:

Input: 616 698319 162880 935414 834873 936137 38228 618256 750290 714177 951404 892576 436009 16991 513187 584846 998205 631995 979630 627356 592173 886525 433795 792920 522578 322198 742934 899525 398850 977926 929753 563942 333329 521333 175554 634508 810952 543507 154699 859299 381689 269283 593504 143392 936983 756417 84833 164426 814149 555997 191589 336414 494688 143005 862681 184944 914438 469744 476356 886772 633099 352795 88654 565601 929588 525302 125848 830522 538430 131541 404695 814171 18524 727619 218405 779359 561320 373467 177653 189469 316355 157502 436819 314238 924251 919094 931395 805312 305251 271008 381609 227469 474410 909932 47069 166176 134840 694334 443013 462067 870875 625310 743844 339983 774464 520815 139007 688520 13142 161551 492979 24482 620975 680583 55268 244597 …
Output: 11

Constraints:

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

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