CT35077

Nyssa's windows Reckoning

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The tallyman Nyssa has been asked to prove the quality of the harvest. On the desk lies a long table of windows 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 <= 1504; 0 <= a[i] <= 1000000.

Example 1:

Input: 939 896432 897685 483934 391474 436454 462368 426680 196957 98755 983944 401906 151714 579759 295085 261856 302115 565715 498624 765450 305938 426706 172899 94068 465341 734478 180131 84438 525825 321337 190584 334027 550780 157632 570814 398632 331170 658085 412943 47244 770471 158869 879876 391877 896037 990486 929435 421941 221442 919300 260639 451320 11741 671122 118503 594535 573715 738995 850778 6313 79553 57854 687444 266559 522013 479308 706929 98331 996457 872775 391566 32657 725744 819892 437150 106436 320019 407960 595870 790005 834422 845155 661592 412467 213145 959253 784180 224348 623195 322562 917037 251010 804223 194495 460978 442906 223401 826625 608321 539921 881265 183535 86301 113026 880280 945797 63330 915910 11512 480243 600293 977752 326755 311720 301170 241175 65736…
Output: 8

Example 2:

Input: 273 272064 861219 182886 472716 746048 112509 44610 117351 297942 336888 656733 667905 247642 875206 951050 648811 424396 545962 120873 866161 682105 975071 773990 360789 410850 314546 887359 853669 570417 563785 999009 137894 795280 696243 378452 574864 721807 909739 262309 656655 228630 748868 618993 13818 739693 543969 794062 308516 288954 11382 211008 161928 247222 891161 625018 770381 803970 834403 870751 126572 541368 988736 493932 141535 262247 954511 155449 256554 890356 11013 402860 68948 314116 899208 404277 947922 286532 464239 592753 889285 30057 563909 848792 68564 461709 498271 875190 541542 513245 316640 388082 101057 901448 966971 69461 863829 442507 42596 335314 323345 784458 527571 199981 219464 247103 441024 134774 150534 752365 425779 575183 202898 936158 409667 435911 …
Output: 9

Example 3:

Input: 173 845114 327903 640686 392180 409369 85273 681043 283623 62153 535592 316929 105360 203538 634146 581101 146852 430067 338726 678158 393836 611650 615077 489596 199723 631568 354888 2603 351920 668143 707798 312022 525564 830645 619517 372279 423296 27101 522699 986799 956771 142814 534100 582189 489903 134677 252452 421013 616557 516506 478251 831358 889710 551367 833136 862497 569570 650190 362097 25921 735639 920661 978032 143706 266574 682011 564525 824567 919933 946654 609307 957319 863232 750992 193188 479184 906132 714349 230326 575652 800753 414169 419736 801352 559617 537398 261130 110616 416679 438445 404587 677980 364057 655002 745914 16753 773218 186398 810597 356886 858065 335391 701524 742714 656180 963044 520978 659470 567980 683203 969832 925254 517051 568432 176191 23093…
Output: 11

Constraints:

1 <= n <= 1504; 0 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Nyssa's windows Reckoning - MEDIUM Coding Problem | CodeTikki