CT33535

Gita's Ledger of ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Morning light hits the peat bogs of Mossgrieve as Gita 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 <= 3665; 1 <= a[i] <= 1000000000.

Example 1:

Input: 3225 890470922 848563786 717937071 829613944 46331345 374765079 992684941 267669226 927953270 320529815 387705090 247170192 10607028 634731702 253824301 355067761 763445349 836924774 148891298 522193582 303842776 992978778 152279091 403479144 525054642 475884756 867420046 266068272 625115399 454013078 157329322 90499626 236925979 273161739 371786385 874054251 730071708 239076378 469167034 556328005 253784173 775647204 672201662 518658019 272060455 756595647 937383831 460521364 789246290 329350750 115643763 883205136 66462717 58111248 136514398 483334565 57561164 153461408 58517541 644131256 2295961 955561006 955272899 468077637 821050991 16084846 415418583 446375887 418244403 616490176 937646735 534108793 469099651 666762854 321672371 167549485 157374306 14460683 348233969 291575449 683324…
Output: 15

Example 2:

Input: 2531 941395693 671810067 436126698 990544580 825052971 576728081 75474634 789473126 134118742 523730337 986675622 419133314 242334537 908871136 660450167 81840660 535963611 514745905 912930137 305270418 198302828 450944841 184758654 953350985 69547027 109338756 336080547 397424405 470196349 509936644 793002669 805200039 568425351 89484329 427923163 609006128 515922339 681144570 124988656 964408640 403591973 682402737 759510984 177976956 745021510 109418684 13135156 680560146 562009270 722337314 454154263 594718892 835251607 148737135 113155500 702624639 394410204 4797249 9251206 3918003 154127590 79883374 205962238 915949893 637708042 771096226 219043721 72247262 429116587 589573620 349374856 657754022 727330355 942963802 956855850 880804968 832468177 111993746 796822794 239139033 90398677…
Output: 11

Example 3:

Input: 1788 565659844 83070631 342834289 509909525 971284192 780137047 731444943 636101926 377662047 935017759 749397988 995698127 84417554 595881516 171069834 585024736 928298397 478984991 559497612 661241012 825417504 719791452 540546951 319445478 565339611 518925070 81407863 285540714 863754301 944622505 260577061 958588982 340576878 5867261 961047809 819557361 533642642 179300098 39900094 51855990 454396037 558733859 154725050 777748248 749668974 793280640 475222710 725699498 500531887 768308713 650710606 272080699 131007385 923423855 759740937 649472383 14502921 901861185 583859861 194582976 803417736 520057412 622043833 896328400 832307364 526093053 703037706 850068598 895117858 218421689 304155418 811020868 622730334 34666695 305290719 827997240 281756700 114306592 533920918 911177786 6898…
Output: 10

Constraints:

1 <= n <= 3665; 1 <= a[i] <= 1000000000.

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