CT29161

Rosa's Zigzag Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Rosa the paymaster watches over the quartz ridge of Glimmerfell's stores of windows. A careful computation stands between order and chaos. 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 <= 1537; 1 <= a[i] <= 1000000.

Example 1:

Input: 119 145259 52373 306031 749274 102566 491716 847415 192008 763251 66334 292625 789547 661442 786844 634309 219250 248652 648586 3702 294113 509551 886088 638342 92489 328155 211647 877723 316374 20320 699022 275503 387955 121684 736227 741318 182987 876732 13833 561007 405342 648182 591517 249927 117603 299755 46353 971312 425893 771139 666802 673827 190555 235815 517824 469426 608945 525348 306025 852600 485206 63904 216172 776336 210999 788371 150284 444172 664057 393000 415733 616352 300552 235198 698467 354185 840138 144674 739612 582008 912210 129689 312951 634921 963183 964481 265756 724032 429780 257584 14407 56090 125994 769631 887754 43687 470549 789918 278676 343135 795181 456304 289227 589105 141591 242127 132117 588154 277136 123090 981785 104851 258989 421470 806014 170606 348…
Output: 7

Example 2:

Input: 121 592840 81866 888976 803571 509472 575421 629519 955965 476931 83268 272118 457322 723270 656987 468223 880018 574600 253102 733554 163682 451241 574641 239919 658055 367861 936772 193382 43631 972642 663809 816744 699555 655087 239560 528168 57588 844307 515858 71242 628984 70619 199448 226421 212699 424023 299613 916559 823321 968854 684112 86273 546718 483923 616607 730601 625574 583811 126980 54886 195720 206634 906401 604819 968141 736942 33011 598604 401080 134182 231062 664718 536972 912517 883571 384300 768658 10009 480416 920013 842984 384026 423820 469555 397734 136419 80115 708501 679276 959728 605157 872089 333720 618526 825934 641967 491712 453290 410046 931554 246196 965012 133156 986239 866421 982247 67308 261367 506736 196016 183655 2992 608434 773556 636489 309317 52424…
Output: 6

Example 3:

Input: 19 105423 660459 790250 758146 858542 340226 67843 587133 80800 846281 805816 102076 875327 658517 58560 552675 364824 13833 630439
Output: 5

Constraints:

1 <= n <= 1537; 1 <= a[i] <= 1000000.

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