CT34313

The windows at Grapehollow

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the terraced vines of Grapehollow pays by the answer, and Zaid intends to earn it. First: the full register of windows. 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 <= 3961; 1 <= a[i] <= 1000000.

Example 1:

Input: 2259 522452 185762 475256 752139 614800 37055 876899 119775 407617 722815 610173 186606 164216 553764 24431 435262 994829 359805 794634 797367 9116 346429 637922 304278 232145 347018 62912 431965 610235 534703 288417 556593 321131 943876 956195 664600 295203 253406 985553 203358 75570 558746 810938 841119 150067 942735 13989 225228 395117 279315 572593 682828 866511 905856 793323 419885 66946 513656 763717 444528 434271 276151 779777 93013 753775 303191 992315 501063 338190 882602 826929 275964 113138 11491 384041 439787 814901 518779 39801 817675 27970 879026 505401 684550 696989 61183 987448 42035 908284 400059 143542 822925 762944 489668 584547 294699 716 340377 597599 675976 992388 650346 331992 311165 72375 2701 471055 606129 338717 441904 204828 927274 962767 277451 306310 261472 234…
Output: 11

Example 2:

Input: 3406 665127 236394 425674 293366 95001 283067 217724 385962 395658 900511 55967 229231 648627 538477 286756 799173 883504 617996 844379 313683 814518 366065 683713 550652 845288 981592 348701 305527 741425 997480 195632 592418 738714 940076 538170 411257 413862 344435 842766 27614 630053 881395 317900 657528 277359 663030 463683 317509 632564 440173 161174 64806 667889 141627 665192 57587 546450 734459 292201 702299 878478 542989 402792 520644 907819 849224 695583 205065 699801 927974 407239 842058 193011 844359 733403 189154 649579 43199 772339 306793 744185 246306 774246 292760 842751 22003 417313 897063 951242 437760 159193 190717 562084 571719 168984 145302 488629 738280 614902 152281 755787 658614 208014 825584 660292 390319 988789 750559 764080 295060 693701 424022 287806 331223 9295…
Output: 12

Example 3:

Input: 3395 17248 460520 400931 436343 752748 59626 705318 953909 769013 890352 268654 291162 393076 533511 605366 170097 585945 884668 264258 583585 866094 686379 49737 62136 418861 84842 467927 155475 568048 28806 298512 125373 266725 563156 469973 55680 52797 956162 144915 785612 518541 629976 831007 606358 148855 995003 333585 884542 290805 253535 820632 140243 341685 501986 972295 149928 285765 273096 430921 446800 510593 174770 791417 234153 679372 393481 166121 25474 486069 284676 462279 249683 842746 119563 749901 659344 421561 266985 835273 342472 875153 927103 367854 276815 553630 2821 484743 975732 283606 698010 241099 153400 281358 437726 294353 883545 161865 819408 358679 436269 249678 664688 366279 453972 189678 909526 168106 819128 958366 167331 449367 400911 386600 237651 312302 4…
Output: 13

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The windows at Grapehollow - MEDIUM Coding Problem | CodeTikki