CT30823

Dino's segments Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the cotton rows of Whitewick, someone must plan the beacon maintenance rota. This year the task falls to Dino, armed only with the segments register. 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 <= 1996; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 890 723292 -649271 -846287 -781264 -469355 -2784 893639 -686706 -432298 921260 349310 -966631 685490 -326025 -495642 -485841 959447 -279661 -98411 983216 -807992 4700 -3636 -604916 391218 67492 449503 475484 -842934 -265584 597533 -962467 668323 -921523 854764 485371 801718 -514206 -189703 -600488 -703103 -792025 -343951 -737767 207666 539744 27823 -724765 -433580 -7950 -900977 -364269 884468 -574296 -294524 436453 -256119 -705156 371455 521835 926200 910159 -829421 644466 658176 -614929 -975477 440659 -129583 127881 450628 -286591 -257488 478086 688760 812101 -968856 257938 482122 294113 907733 -684561 627609 -864287 -891818 -436912 942351 -553600 -583926 222251 279086 730216 -708732 942974 618706 917284 738776 853138 101158 992917 -32721 -98144 408308 568225 -599858 -212864 -197256 -9737…
Output: 10

Example 2:

Input: 1114 567104 199574 -828551 785042 -406437 45012 270473 -755048 -179865 553859 266007 -78662 -412963 85107 -560675 726093 -359 290893 -21676 878486 -894961 -627331 -734932 -237949 -277347 -995859 -875382 505362 309225 742483 -829431 -512739 15232 716490 -369540 546894 94684 -543719 665566 337846 -677581 419517 -334313 -48054 289749 783372 -995551 -106422 -781325 -933736 -250861 -323402 -798293 714321 -261633 -661756 204645 -749082 -240878 -890698 352019 -415390 652697 324982 257291 581502 978898 978227 707822 -485265 442256 949102 -32744 -238521 600522 -44938 -289013 -9750 349516 -858161 376966 104551 240919 -669670 -379716 99513 -690931 391999 -918698 -601784 683226 127935 -581434 344542 -388279 571011 229099 803824 981185 -797584 -555709 420974 -403939 -857827 116415 -983608 -287903 96891…
Output: 11

Example 3:

Input: 799 819232 -864664 -420981 -195094 235137 487847 -264573 234358 -128136 761494 -747007 14418 178422 -685739 720423 -327447 871673 -61347 352920 -614072 365480 -604166 633370 -495155 418656 -455710 -779132 -203359 833972 -1944 339903 392743 71056 355285 605885 679594 -517930 804085 -539387 -549373 35508 -813036 305207 -58407 -46933 751090 75912 -493161 -828531 213570 -97124 -931688 -442518 -378967 918733 -459473 584108 -665677 -618764 312488 -171760 -753484 -750926 97767 955932 -323260 981274 5152 466188 -505141 -792979 -704594 412976 -411641 -889199 667041 -7911 480461 844115 219929 -672432 585571 -56942 -752521 292983 -734399 -652976 -488642 894347 490275 -103614 -636412 -894859 415047 439322 3297 -668817 734319 872345 434391 713738 -846491 304743 956768 -755585 -269034 616507 68235 -6857…
Output: 9

Constraints:

1 <= n <= 1996; -1000000 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.