CT33911

Sara and the Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The log keeper Sara has been asked to plan the festival budget. On the desk lies a long table of stretches readings. 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 <= 3600; -1000000 <= a[i] <= 1000000.

Example 1:

Input: 2313 -33622 825671 515371 -952491 -908198 -251951 908905 -191454 -810183 -234486 -609405 -628062 966640 981023 833815 -65299 -457750 -15777 24918 -809414 398110 -54933 -950411 648491 943991 -527584 -295880 797462 552393 132763 286355 262245 404084 882756 615029 -613356 7321 589939 259876 -408435 -992391 -767685 -616945 583073 -541616 237726 182748 -146680 -372818 -968777 -224196 -335403 300575 426826 506475 -155020 -750688 -708564 294854 87673 484745 467582 610777 -203678 416314 774908 9667 -754475 674467 771334 875003 -363432 928569 381365 493527 -363729 567831 -871472 766342 644456 -401835 -712893 432459 -917012 -182004 -932990 -247205 -598759 87368 520105 13195 -404849 -956845 643449 -440381 436995 948085 -748167 -24443 433387 -464134 -61367 119190 851244 938940 -551016 -790980 -650999 …
Output: 11

Example 2:

Input: 3314 608324 810515 -79273 -880702 602687 116276 376341 -843275 -453386 577804 453746 -962471 -852002 820822 575886 -209046 -642161 484709 248492 -727177 923802 -426111 -225877 655289 330732 363924 728000 575943 791071 486558 -996585 91868 -77843 -766565 -598993 875983 -700709 -715600 -111061 -738140 270056 -78529 863094 857205 363751 -41925 -381315 505702 178585 405391 -193320 -295479 -197383 -889244 -436992 -69098 916476 597566 652758 722668 -977380 479716 88326 585513 -276151 -155556 779596 366510 -518433 -632377 557995 -348156 387125 902870 -207351 695212 -644690 627035 -394275 -473566 715279 -165272 880826 459097 572360 705425 -930007 7106 286771 -731209 -901197 -503326 -904121 -237162 -542096 -627605 -776528 -475081 121265 501653 55750 252339 51851 -432026 551237 142044 344286 548690 …
Output: 11

Example 3:

Input: 1379 -600023 -952377 -54985 579758 -760596 -158698 -345784 -795110 -737442 -314831 -823750 -776787 5466 319866 532006 790956 12326 664775 -361790 890659 -567202 -832218 -947455 -968014 -200959 -49761 -357354 796796 -989794 -388480 313268 -152074 940858 -836844 -196918 -810516 742713 -391804 -510474 975696 -326187 -434597 352559 -751180 -772051 -299994 -301545 -786415 758626 -829755 744206 -6500 -608558 306677 825429 123146 464720 -745796 -224664 366025 929056 742000 -400919 -38738 331905 -854682 809862 224604 137157 -94088 -82379 47206 -359897 -68948 577665 -134324 355271 270071 901393 -300382 228391 -829237 -899751 -945919 -634354 192712 -687405 649488 -662589 -1433 -451630 -259916 -233948 -390084 838955 88545 837155 921372 567519 211586 529444 388579 921525 264073 -164420 492041 -9268 78…
Output: 10

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Sara and the Checker Stretch - MEDIUM Coding Problem | CodeTikki