CT22058

Farmer's Shimmering ribbons

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Farmer runs the salt store at the bamboo terraces of Verdantstep. Today the books show a list of ribbons, and the numbers must be worked out before sundown. 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 <= 1461; 1 <= a[i] <= 1000000000.

Example 1:

Input: 1265 540200501 512316681 940316598 975657136 880832425 221984656 54692244 366468191 403090922 366535377 519098891 944750750 963538236 528261107 741610507 114574412 52244165 160800325 479201826 350448302 839545124 37956246 456277931 525840094 85761366 346570581 224364070 495606122 226540322 17890948 497046616 733488341 216889939 852570536 673428519 75116664 301809710 656892096 559385605 537723629 656866845 336126977 875475152 491576231 96348059 96617065 892312164 685376564 359283227 269015096 577631258 794176037 449411082 394122238 646212219 839747678 340150441 915321665 286956077 606572288 766857558 762784966 488837590 442124296 168049383 941101617 78343989 264585140 576191492 422350306 96124172 574153190 669453032 50023208 700256627 501880670 416951256 787821017 3071182 470470839 11054172…
Output: 14

Example 2:

Input: 220 329834296 458019833 474225387 439854934 775577998 988808638 759283670 463539608 718478610 864987566 535619120 339238757 106114901 921232840 232015448 49220510 427979948 140607949 387564513 76415019 3164847 622739769 880719680 596212081 217777772 427596362 419385625 685506845 318014177 552831320 258999880 735883411 78883148 849795162 47176786 725547608 850854541 108104823 707861710 534725421 645058366 910399495 838001592 564896765 690251416 417755887 681317951 348694063 716564513 381170929 585293114 377797496 413662482 82293737 878671678 81570688 400039700 630502641 658705840 943223490 811263582 206996273 327702989 299224919 136022723 427031462 773368559 749451459 390627769 960321197 855977852 784291925 228323290 298271013 977396859 607204887 370333770 479715800 934158087 59029494 36520…
Output: 9

Example 3:

Input: 217 589539520 547856988 205843416 19473225 957837917 440634781 906330890 271415221 628737719 884993470 502667776 790121961 898088362 253089380 693097591 539537245 208506424 471393157 42663080 361784362 661906614 404933290 945805969 17924277 452018019 694411203 728988894 51581467 143659376 142522997 54584912 699279507 41091185 120836961 470843387 232349705 812994243 379400317 664041341 42976685 580574101 77642602 892253196 547015002 243268329 928052959 795054280 378539903 16207859 298113987 689417909 939726563 936307426 670624308 991046043 704503086 886227624 624530920 645355612 18642798 614333850 396783934 734597013 805751782 644461423 930629701 182077304 713396800 722673769 340135790 923255829 892759639 697063930 385825089 840428211 273579633 398570593 816251432 877379927 750393685 982593…
Output: 7

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Farmer's Shimmering ribbons - EASY Coding Problem | CodeTikki