CT34483

Wamika's Checker Stretch Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Wamika runs the depot at the peat bogs of Mossgrieve. Today the books show a list of windows, and the numbers must be worked out before sundown. 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 <= 3686; 1 <= a[i] <= 1000000000.

Example 1:

Input: 2211 562897731 720320343 631953266 891189894 354719365 193044184 112041117 284215282 427499280 792953103 942960557 923850937 23353181 212104771 759663767 766361190 851946126 836852271 185164278 17481038 108516210 658424825 222880756 931142848 517162156 467217258 457846500 949059717 627631307 343380920 148506046 998972275 794450924 423443904 73000466 756681110 201743050 214892512 587898637 681372865 451544414 879862086 158253611 96591015 122862599 892382608 222323929 282368378 804274858 714536529 265882041 664450319 530502013 969102218 559382542 349287742 198784360 485084466 507634255 923637512 378753619 816137652 300675547 503893155 883580038 249256742 157093184 110566804 899854892 722495484 434759511 878196554 44291525 408413514 492447721 942100479 824857970 882384003 759221829 468906884 …
Output: 19

Example 2:

Input: 551 125687694 311628500 76154935 479240408 302613696 720109114 398107615 513116640 958294759 621500072 530183843 676553804 40160480 719467773 829256525 101515337 214872495 241339244 564240639 140380844 869213981 392699071 869704037 86626410 236411180 781572869 852211118 825056550 838072199 694256967 213118933 383051271 560885698 540766904 72340269 979147215 393771989 992538268 939220191 300351213 207972362 367014386 395401070 35232453 609348886 225670180 812854826 428731215 46651810 913787265 818202023 285452495 306510827 84785683 779526190 398746031 845328265 248246005 406051811 392021347 432122840 36001015 609200054 315813036 710323918 938464415 463819808 464121015 40807108 718189429 419038174 188245789 377532875 662927727 888399982 134860211 714674211 234848992 294327049 578453449 75543…
Output: 8

Example 3:

Input: 3354 777813717 618307239 355765902 489071315 888388839 446739171 130759509 202689894 422086119 357960450 459683082 610080963 431248075 623961132 360310440 471270172 360220916 852789564 277854418 875729772 563431302 92574581 472591460 492943798 696621911 769509598 800054492 749171194 445400439 146245631 324407573 579094053 165598695 741482677 748415527 15536637 604312055 526825391 233896239 704482451 466184511 408054764 324536631 324140303 904028946 867514244 454148048 888439224 621673478 50064218 628422469 489380663 25376955 12471101 813100810 223355807 492674973 301836050 611813226 961002449 499959215 718179221 780234441 949250401 987990441 707168485 681252517 305645218 114460475 901951726 711779759 886087348 774982301 156967558 256716424 68867364 11208991 374457570 246231753 659671236 48…
Output: 11

Constraints:

1 <= n <= 3686; 1 <= a[i] <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Wamika's Checker Stretch Ledger - MEDIUM Coding Problem | CodeTikki