CT31121

The Checker Stretch of the Crystal windows

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Anaya inherited the foundry at the tundra station of Whitesnow along with its curious bookkeeping system for windows. Time to make sense of it. 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 <= 2933; -1000000 <= a[i] <= 1000000000.

Example 1:

Input: 1576 627505474 552058797 72844238 568265586 593954723 259981151 71724806 999818792 223436358 162055061 463398248 717168198 144080465 441617916 938331090 966245818 847228171 756996357 72114960 551389472 784056903 75315243 322672275 962455268 159899596 39275964 750890020 219407423 532564194 565655034 643797487 589480686 53805860 575520257 504601284 951568291 706253553 987324126 162930833 981692920 42487102 867657250 824127377 465065950 516829925 516549174 744208756 921723877 132670444 317705256 496377617 493768977 703083411 846969767 125936100 105577472 856111124 697967924 41514080 791632146 381913832 216131159 322925264 986044593 174869756 389192534 721320000 397060178 780921429 412758428 431154688 642537605 572612280 952347780 409845935 450694675 973943910 847190301 89173680 564828516 8373…
Output: 9

Example 2:

Input: 1687 613971995 76400340 45032589 963167838 976800746 553359464 605097961 131808752 949238723 748418982 408894872 156783144 761860663 23807533 541357369 386305237 932294861 573195899 228024985 346542183 456657828 659853110 21642317 95409136 944131746 799366410 964137496 778400958 367023225 254240345 490914488 767278307 47387119 933469858 122702349 567923360 393713579 675378341 971015911 887788446 735579895 900853411 407593851 603832632 287511146 244006668 823327113 393404152 438522409 640225986 690676766 400660660 554216352 576686643 371684087 948514732 791401477 267785005 520048885 354483757 73316571 105373500 804689629 458026024 262799424 935496098 153914684 759105317 14403607 713040107 908569064 288712394 943703723 70604874 447912285 664087054 984221134 773851843 751186614 100522712 2357…
Output: 13

Example 3:

Input: 1908 459901468 551724542 143831045 127855419 693963042 88062253 546886769 969721839 64495477 10065183 962268155 194580818 364074425 862898773 450934695 765277574 290817164 354998197 227707301 527962074 394976818 790276402 526316661 537530781 736125172 503817135 237301872 876328491 456008703 956612445 397046943 473276195 487571682 325964964 594185227 326610673 312303191 636333868 31246915 19916239 660205140 669281399 12595924 354434221 214859198 267150788 162989471 274966941 606858890 117672922 809745365 999277069 133797313 461560200 942357299 237615766 662984765 449097616 325642791 75544034 154267450 34645719 292060470 130680437 823151716 558022244 546345392 427649995 758879023 604869479 638284200 480471001 783470858 60081386 808825254 960683292 212425974 291868562 288399749 877951144 5726…
Output: 12

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Checker Stretch of the Crystal windows - MEDIUM Coding Problem | CodeTikki