CT34220

Eklavya's ribbons Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the heron rookery of Longlegs pays by the answer, and Eklavya intends to earn it. First: the full register of ribbons. 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 <= 1352; 0 <= a[i] <= 1000000.

Example 1:

Input: 633 794469 938678 411100 321422 783915 623591 518282 702589 772184 917280 746242 880165 485671 525763 601209 753284 746917 482599 980153 88699 677605 403330 72368 703460 468841 428580 399358 866331 750162 191904 598360 528339 503453 585872 96745 596176 845250 644020 56158 677279 548024 295446 451911 682097 982854 970748 462613 444604 429073 699520 402980 69802 598386 840424 210773 614391 791448 864264 641860 284397 378974 231194 279163 152267 46609 973436 589175 935023 668470 783568 983800 391099 21809 179485 982387 237164 55388 392018 376507 437307 48284 895224 507699 565831 331866 510677 557066 963604 308823 537935 48610 327331 736259 913273 845389 174557 432846 877268 594227 59101 313934 886290 907539 955210 44531 241033 704440 49250 88393 837141 647419 601727 12314 279833 642270 717490…
Output: 14

Example 2:

Input: 1043 505923 208029 571115 666653 212437 105214 793549 25118 217560 185153 844260 568301 788741 33765 876712 320417 278704 880916 147470 888127 1878 346347 162458 522969 795835 521823 284754 659280 401257 958413 66401 187695 337062 764938 794340 588322 664294 524170 363022 886155 287264 592800 868933 217806 870034 336598 890790 855741 977958 867649 933109 660846 580496 263011 76950 784573 85226 995950 16818 342830 962913 92463 943051 594779 421383 501803 375536 900407 366765 712292 519827 260310 461644 7829 471280 893094 271852 226152 234731 335855 493210 245526 188843 494998 154957 368265 828577 952255 601456 179194 805978 917878 70820 905040 592390 99882 322875 497722 983793 725074 204019 315986 113934 695921 463741 141488 251220 102534 105355 919664 631509 594852 289795 640747 682496 750…
Output: 10

Example 3:

Input: 605 355679 241380 995509 978872 117313 937632 736050 779354 22396 462479 805589 276993 802725 696085 674315 153130 97363 41243 833955 298161 960994 190429 576634 399933 638873 619446 376925 67733 371784 722117 199241 864932 248528 638336 381816 315469 697600 763457 876619 734109 620346 614243 91962 531422 124846 193994 975552 895576 646335 806505 547236 952688 770656 764744 27710 514366 584547 79962 622201 393620 291116 685485 538666 478141 605429 500228 838264 649535 217598 859774 459940 709286 463723 801106 739465 557339 825666 512509 39835 401321 901001 381152 252098 142352 557736 451405 273444 647405 914338 213443 688030 543262 505102 742335 679656 400354 994230 399925 734296 367424 565965 99229 671348 731376 348223 963126 142568 462690 784082 628259 290346 237391 890350 701564 805978 …
Output: 9

Constraints:

1 <= n <= 1352; 0 <= a[i] <= 1000000.

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