CT32350

Fiora Counts the ribbons

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the foggy moor of Greyfen pays by the answer, and Fiora 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 <= 2752; 1 <= a[i] <= 1000000.

Example 1:

Input: 2283 86375 556944 401608 418105 306854 881915 619101 866622 229975 668409 290010 662311 364903 495932 167880 695183 848800 285073 362646 196887 512547 397218 193432 195199 92327 483283 622228 591703 153926 838445 21838 257700 48168 854326 885427 797032 411291 916211 124489 707874 216190 918812 398955 653015 718000 632661 244208 238659 687071 181507 668587 486125 122295 864850 766221 764425 318577 511092 686526 630557 156810 830452 525617 705562 347409 490987 142047 977462 586855 549394 193615 894521 468036 122001 700033 819872 127332 739537 974615 170403 35674 662577 118953 845683 949827 827683 603822 880408 501860 930207 273114 964222 702726 16847 489505 965756 12680 689899 124065 524876 473118 552924 282754 699044 751689 715187 936757 182581 510914 158509 652843 623002 681907 188670 9805…
Output: 12

Example 2:

Input: 1987 844325 427400 579689 212744 391197 371616 958623 337528 129290 78612 480391 686110 226602 541820 292935 19732 876563 632103 12767 109516 218995 541998 555838 616174 2715 188994 750477 534964 989757 968751 777824 159151 54112 446393 871659 881945 902383 626070 510740 129362 716918 237644 97623 6600 180304 520016 312852 328109 659815 192562 950951 423220 157395 503389 55324 770506 357636 940971 992966 230684 278246 413166 360481 999107 478792 79833 699580 845958 894751 811996 74031 997635 829547 149002 572431 502647 441645 111476 468671 670723 399021 403938 394189 789366 183319 514142 129481 449145 51397 682155 694373 734515 683309 401084 577350 129637 898807 894413 854765 350154 360823 311213 326797 394326 378107 329487 390340 144192 498223 804117 216356 514500 744781 549667 876887 676…
Output: 13

Example 3:

Input: 2737 631524 104352 932073 942536 534374 249854 805165 99767 552096 292227 363895 481603 697201 693229 712529 502672 27999 954803 506247 118247 432147 14254 34889 611380 514195 537632 904917 502560 414646 669526 967650 825877 827544 630933 220227 10164 757515 79544 53100 825749 821537 476370 414307 589133 762984 686413 482884 77712 413931 381735 663031 351311 161491 681331 381294 335846 794294 984764 89929 884657 302900 507595 357085 777246 99533 307987 380012 841504 955403 917323 806676 922851 982998 26045 713366 862383 784804 654363 641749 555411 732875 167659 712387 156079 124033 353345 224398 949884 746290 690645 171423 332452 522493 254209 895166 422692 108383 933892 883028 587268 873098 741998 676959 92275 341338 175746 394553 260913 153173 555940 214432 526321 298951 448193 537049 41…
Output: 13

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Fiora Counts the ribbons - MEDIUM Coding Problem | CodeTikki