CT33450

Nora and the Wayward ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the pearl fisheries of Nacre Bay as Nora unrolls the day's manifest of ribbons. 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 <= 2203; 1 <= a[i] <= 1000000.

Example 1:

Input: 2037 457997 496338 616353 440491 542253 246210 209189 610208 551684 859502 765112 687586 864240 915358 250595 918740 472152 182585 365170 27594 689823 677224 990281 304746 269351 507297 982619 419395 267100 415614 42528 663512 277948 553716 393181 947126 491847 777738 501435 615968 769876 391200 700382 54591 433891 179130 156261 854966 687032 878556 636598 652918 465061 18511 781314 160720 21656 335514 152282 629043 687850 175131 553019 48013 14525 710680 741512 668594 86525 671855 908559 798795 785225 612771 383686 172692 924969 733936 764169 980334 709040 268610 701914 989926 566846 893788 614587 679830 221777 139931 845412 673813 109538 116164 736797 593031 45655 855678 44634 831234 480200 540021 61286 198067 658470 931303 422887 437392 477046 451908 847555 467914 303562 33550 862280 38…
Output: 11

Example 2:

Input: 971 456417 328044 824882 219682 252858 289193 626731 464736 287275 204944 186696 601179 540374 70605 95069 107955 913679 250018 823541 326105 423329 302575 836690 856778 418865 676176 682633 462507 472916 146967 216463 547349 182073 676953 311459 745253 11845 617469 344928 989800 583516 46204 703956 390824 296410 216254 573785 444805 808169 380122 565065 984884 56763 122974 204617 173971 996279 10316 817312 867472 262764 715824 742428 805307 122358 136346 207270 965824 464430 949816 149683 947789 462422 799803 183803 184853 58887 633884 654577 983570 692182 555836 403773 194955 378243 808923 746120 546336 991194 452804 61915 604391 140513 260346 564852 118396 41324 410303 742807 465286 426477 732523 850242 528573 783449 279378 828214 295963 865954 704442 494955 717843 683945 412060 17759 1…
Output: 9

Example 3:

Input: 1630 51782 591025 565624 640664 846161 860628 698862 724039 37414 33273 498270 626706 392184 380309 521238 374233 281588 757438 695500 840414 865203 588095 475071 64158 976622 125718 300859 397209 788904 814774 449440 518324 278100 462565 3358 500504 833268 101049 233677 376999 152409 719588 500911 959861 990023 54417 992211 276176 641018 140421 925773 656896 892096 551342 458990 878055 766721 200336 912458 488490 277814 3397 143986 755936 943865 483955 453570 75053 645320 999271 173646 420724 158804 460250 673880 592337 931361 532717 662371 791810 590475 129372 965925 333240 478243 475308 591742 354636 937642 870390 763101 205849 948264 760632 444252 468594 64321 621492 318558 949153 883440 686497 336817 452141 569534 628989 998717 633770 953091 377718 319105 619741 599173 846145 722676 5…
Output: 11

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Nora and the Wayward ribbons - MEDIUM Coding Problem | CodeTikki