CT30477

Petra's stretches Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The inventory keeper Petra has been asked to plan the harvest festival. 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 <= 1509; 1 <= a[i] <= 1000000000.

Example 1:

Input: 468 924998882 750116892 246416876 581955142 309448167 316643063 518308229 805307665 146284695 930427247 851848140 830854982 851007103 464229854 920503625 798401109 104946740 581187732 789384510 836674475 162856668 513011509 665010606 271430996 89958411 81765347 556613278 589520863 882706436 389659628 668361027 783013980 811814263 267235478 774551385 977184007 882013701 164683596 30949691 820258887 179606227 787330549 183630398 681562788 933826915 478520485 303767327 422939823 473535694 405121953 527348532 593374156 596367615 223674271 160992841 25148598 472904008 794942484 578999010 308626763 226592127 739416645 172382345 91778650 594307936 539762232 93805531 685860524 178034406 313703362 47386590 51891647 526265889 382105160 106874248 130958677 204624357 918620439 927268059 65495922 27631…
Output: 7

Example 2:

Input: 856 541859653 968404025 734888225 57640888 265157252 301463652 627722686 112387466 157640054 337104295 622253191 904053251 508906250 907621149 371862124 540564624 918279653 553283277 818321594 112546597 495872435 607484290 648180832 642075505 873428680 248877146 842166226 72229608 369321734 947195702 339854387 581964050 780246202 670056781 482142654 572426490 414466576 94628813 162615435 765958061 331191848 475874777 423111205 791825619 608705922 31988300 173778535 389578954 151066490 125889704 677612230 344790960 943151488 580016345 57317624 237460171 30200148 145237120 439323688 893434893 526491911 193923844 38832867 454616467 915437218 413476778 394196699 215935716 446583185 681597965 508211767 788788879 6022421 537931618 603093045 837170741 852316750 284362861 315486331 690398231 63555…
Output: 13

Example 3:

Input: 1092 384659856 597481212 738930056 291293862 797589979 604955671 526510200 492457296 329721632 612020011 523169962 918663334 234209752 990352178 135271702 817463771 410759546 426864945 563686026 586213254 365088691 954084094 297358676 679037782 601019881 4432595 634393848 188095131 598619765 423400836 117130067 360715026 630179914 993781985 684405076 797874143 24432921 472902731 872007925 341520217 126897208 851940690 574752915 384905215 438319776 213578937 295693067 677976917 191020523 568112021 310073678 435826711 569305451 30450681 430563104 253506409 441000947 680761751 697897859 737958943 104757817 987728741 994354979 56749798 731838148 661976652 99304443 441374105 963559626 184147081 252768421 854532000 257084539 302627987 48502802 20196464 150554178 700061108 366260949 401972482 799…
Output: 8

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Petra's stretches Checker Stretch - MEDIUM Coding Problem | CodeTikki