CT25050

The Polished ribbons of Sara

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

In the lantern district of Glowfen, Sara the ledger master keeps careful count of the ribbons. Audit the season's records, every figure matters. 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 <= 709; -1000000 <= a[i] <= 1000.

Example 1:

Input: 476 -891786 -586484 -630266 -862257 -698140 -675786 -437983 -821274 -52688 -204753 -499333 -895422 -312022 -785283 -850839 -592284 -830732 -680125 -86902 -996332 -826863 -65189 -501616 -953940 -708250 -689246 -25736 -745987 -221590 -655308 -202940 -192544 -977967 -517639 -292703 -233244 -926418 -858257 -123801 -103182 -769833 -268449 -769941 -77891 -282766 -916940 -402739 -286452 -955917 -203250 -367382 -94334 -510951 -462563 -961798 -309010 -675544 -939062 -457832 -476667 -75969 -645639 -734595 -64446 -810649 -930087 -324795 -845510 -702199 -662919 -644808 -526538 -597446 -18640 -947966 -584214 -218716 -641816 -651387 -281352 -841881 -115005 -447414 -397429 -800932 -448344 -641731 -570330 -173622 -799001 -373907 -685063 -426967 -34836 -407285 -443689 -736720 -181832 -595952 -412702 -43689…
Output: 12

Example 2:

Input: 424 -92979 -770789 -62439 -188638 -164104 -748491 -258930 -390767 -687020 -846028 -470854 -827503 -913515 -13562 -535546 -30350 -979426 -209075 -14492 -216245 -286896 -411691 -490658 -115986 -945651 -282328 -856526 -492315 -236295 -531990 -712930 -333060 -748551 -815861 -259 -455575 -193625 -529420 -191335 -461430 -63822 -122203 -984012 -785601 -42099 -664255 -343471 -37635 -992772 -275514 -22105 -249093 -98262 -592920 -504120 -636299 -143125 -577547 -746165 -802657 -696318 -905762 -268226 -652719 -24319 -580082 -525870 -303443 -989076 -373623 -734445 -137309 -107529 -165703 -717513 -677264 -422399 -150824 -92286 -13888 -513056 -30977 -356150 -858652 -578902 -448424 -233517 -819493 -709519 -19196 -443916 -317719 -894527 -433364 -116184 -292388 -292634 -991115 -424755 -164566 -207824 -65619…
Output: 7

Example 3:

Input: 9 -869651 -431418 -627644 -64848 -228627 -376166 -837530 -117222 -816560
Output: 3

Constraints:

1 <= n <= 709; -1000000 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
The Polished ribbons of Sara - EASY Coding Problem | CodeTikki