CT33563

Fletcher's Smoky Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the cotton rows of Whitewick close for winter, Fletcher must finish the scrolls ledger - one figure at a time. 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 <= 2767; 0 <= a[i] <= 1000000000.

Example 1:

Input: 2281 856604249 649897470 635483965 291504578 860058601 848614557 221996644 232670151 336413931 261217361 258689785 738433516 56605308 173713546 807123335 424025893 956344966 956857148 875543252 941362714 395262421 919074615 743628559 84899013 653785405 249828457 599193807 177679627 368776086 64378871 668547107 688816949 595831325 674810643 185740225 412277101 144102233 40317726 804053103 419462481 829251157 630114542 618803846 672290656 274298078 466386709 32884047 643657214 608536632 445298671 753271249 700768390 902052189 576270033 889829478 311342373 306849970 565927833 253556752 637433634 329453588 722995046 656795344 475195507 248310145 582156977 346210864 828757242 668001927 877881036 666264771 577946585 952417574 131507852 121122227 396642112 180613249 256872301 299367207 957468762 …
Output: 10

Example 2:

Input: 620 37969458 922895043 234462462 398841833 48130884 516911433 727770295 199626240 296239614 667916857 91751181 981633834 258033544 186133656 978161842 940390346 188568429 697583365 203311780 878819295 609104143 849694296 269727354 411568726 201810905 674671566 497178299 332366940 706504045 933084381 780413978 293752929 569866154 19182406 128892794 744989 903170408 677045202 540202589 324242992 248054920 999875256 77939642 248231194 416046148 556576175 311580545 123751605 471444602 642687104 941930284 393645311 451251269 426235309 263441521 362037170 302478745 925493597 25399484 879881992 533567061 582177478 813621826 590795458 826705528 462362939 448237213 900030771 898849490 987412257 945293276 494346948 179120798 970518692 604933068 889364853 155286146 794186515 875037566 186456976 16215…
Output: 9

Example 3:

Input: 2340 701527602 648585970 214562760 444257085 335160469 661758417 401446838 524728848 755122852 847822602 954201963 607333509 57625439 485610570 298643322 287734163 551460073 127927671 506512466 841424495 183698797 812464722 818434042 87987241 790701255 997707842 272140195 174133918 355414181 375734252 751169068 671550865 395203749 113065714 822733574 456541768 783032355 541207981 392374926 471781656 662454413 288095922 313635430 151270009 164087525 134510652 876873960 670607305 47346936 691928441 473488842 766707006 809076736 689529321 454793677 80678848 183878431 929643287 970263512 2440225 472097587 847973455 404648174 711428867 1998429 187141664 137980576 216794610 435972636 210495931 603510369 902310601 831196088 286364508 29122048 870318083 527088389 440968008 787104286 260394626 4623…
Output: 11

Constraints:

1 <= n <= 2767; 0 <= a[i] <= 1000000000.

Loading...
Test Cases:No test cases
No test cases available.
Fletcher's Smoky Ledger - MEDIUM Coding Problem | CodeTikki