CT31612

The Secret ribbons of Hans

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the basalt cliffs of Obsidian Shore opens only for a perfect tally of ribbons. Hans means to find out. 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 <= 1762; 1 <= a[i] <= 1000000000.

Example 1:

Input: 5 168962557 652848182 449715665 398491717 641162519
Output: 3

Example 2:

Input: 576 787232905 521209969 329707882 287842945 922664748 33631370 3103726 612605447 558105296 556025011 251779397 878529785 797033671 886446871 804773706 13969823 979444816 893208209 772166495 47787382 958979889 666875031 808732195 214647329 672426340 69439554 381114367 205135454 479980 644605001 335997847 519417281 741496362 413563652 913040286 490475474 51778972 443455362 721147638 896833445 899580665 242285636 777908999 369518869 792514119 576851050 88479260 984743485 145349527 833091049 309044779 839326862 581408279 830132846 706278249 143499523 331130577 856884920 171181975 754025015 159026917 347299626 399505360 740666402 255604278 71095718 272558059 953593202 219030531 287601088 692595101 633125677 170908922 211980629 899323615 306402379 482280933 448042752 207287198 234953561 60247745…
Output: 9

Example 3:

Input: 8 30358754 830184745 916601903 330274185 957291031 549960169 190332739 954181071
Output: 2

Constraints:

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

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