CT29267

Nyssa's Checker Stretch Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the thorn maze of Bramblecourt as Nyssa unrolls the day's manifest of stretches. The tally will decide the next shipment. 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 <= 1471; 1 <= a[i] <= 1000000.

Example 1:

Input: 1420 118789 672976 44890 829077 609364 317786 345757 345718 264219 563495 66573 262768 350348 841114 486681 163553 195807 232631 817403 901704 94621 811951 566898 781995 836964 475563 957314 422919 714398 556496 863925 924615 624805 443736 320292 809285 894653 572129 418494 299735 575985 883407 951084 823939 898668 839531 486465 85092 291543 739728 802620 889475 50729 144790 715347 48624 956524 172878 235507 930031 351771 115339 338083 660553 761105 64285 656047 758208 781788 833228 386056 863784 758287 712273 377405 266068 900519 489170 54139 728859 670706 779942 615383 450748 732356 723458 462772 447057 200259 455022 308352 318318 929532 190608 973286 764845 433409 557577 871208 380367 906455 346499 410857 819274 709605 644957 196232 349114 86008 841983 31540 500982 361103 640661 153841 …
Output: 14

Example 2:

Input: 83 279765 590834 827897 540147 382561 398699 49365 679180 454986 491505 294452 210836 369119 67603 285156 384223 419457 782126 15781 243515 998718 51863 994834 242777 964616 399346 996621 547140 209018 485074 138321 290146 512782 705896 312879 217891 676643 308083 233763 809877 811940 549630 938286 609572 482143 590547 806769 870309 536894 109441 425131 601657 176409 791994 501931 662372 366604 175071 915120 982609 770360 663258 339152 593360 179567 326047 968506 961955 554644 760769 764198 828103 114715 110759 654129 671553 612809 203206 946851 437726 186349 511250 181154
Output: 7

Example 3:

Input: 311 405328 469728 668414 882884 366386 777251 409731 209018 316540 273764 257988 819924 782453 591992 785559 742165 578678 619370 667547 713168 879061 453802 661544 626955 90205 258239 896948 975733 904094 52246 848258 370432 403989 904433 196207 508613 72035 365588 262365 869116 716626 901525 587830 856293 218462 185206 583279 875711 34980 872451 955608 9546 907160 818737 104957 10268 396213 539474 240060 707449 192189 614550 276365 213638 396493 492084 403942 844854 418419 721424 52744 597577 826149 490289 750780 863509 922774 741473 385423 627645 370219 352651 598643 913983 688178 32958 195325 614422 363759 628494 207408 581126 106037 519572 997811 280760 795633 692463 908372 669825 443643 990678 223972 491904 271263 899451 138292 297756 468241 471170 890029 630354 303190 903529 318303 …
Output: 7

Constraints:

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

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