CT33834

The Northern stretches of Arjun

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the trading post of Goldmeadow, Arjun studies rows of stretches entries. One clean number will settle the guild's oldest argument. 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 <= 1263; 1 <= a[i] <= 1000000000.

Example 1:

Input: 752 715175545 952668451 555583914 610451307 772529351 226795708 45633733 855365816 780365086 701008972 930325200 242694614 693215066 366571324 504138954 638576651 327628202 270229081 781583228 14504984 28495946 688533911 526401823 109135031 529591743 491866610 235123854 826865033 82395429 580586409 607215269 203625875 59839358 492715215 734678829 250030115 917188182 376926850 287782511 336910047 25983689 661084426 101345814 349764342 292081980 904377617 558919248 705417819 455744831 318589671 922055228 557902251 626806456 583177723 501787433 333923041 405738907 392335432 602092214 969100715 122169105 779928564 945928740 904161483 698159428 594485956 668167678 364981773 494284211 134425712 539692466 937937626 811156227 921958984 432258442 604857215 560848534 23732140 215949341 959785340 393…
Output: 12

Example 2:

Input: 864 79486609 838237534 578832228 623956320 183226330 406322631 94535371 689279536 707685526 330305744 82193153 6432487 717872311 755137246 375336264 37762646 204763456 396730789 137708623 847463639 972049019 960290552 408200272 119953495 976289943 533606173 783245603 863729146 571973032 433704764 203562253 793078416 499479437 388946178 171409459 559570067 62848138 963746362 534203625 228809336 48828420 852745105 679990579 621280124 543565021 952519356 237598194 642227739 735083694 83589325 395560339 976425553 925029427 895496625 457378940 881899523 74166737 263138532 578162941 173571418 344714909 679432255 893712845 786459398 652842434 361488834 5589299 832524373 867791332 858532759 733670371 894052770 134788730 472547102 339667623 600825172 143512046 889481494 91443772 539144559 346261122…
Output: 9

Example 3:

Input: 391 989997435 755430782 657119191 105438385 403229485 977638262 992755099 408002952 430861754 517600318 83942938 608313786 573716310 269186674 903059894 687814400 894976578 369863447 531302452 169020634 395304836 963736728 56054041 465285285 700129908 931806381 698691898 194780593 738957815 652099738 507863293 207085053 396503204 897312981 668269830 652043777 954067101 414453415 281533723 429394437 979896117 584084489 74778474 697698396 203461274 803508846 647515247 123674848 855534084 115951747 790247547 162514508 848197230 645217925 723605411 809193672 995259257 514169529 736094769 857716656 868336180 391891928 714588210 82217773 260874174 593048639 810374813 759504787 932497395 803813122 590624276 674235067 483804307 25558046 792346834 894179310 734101570 173964871 940537050 962690232 8…
Output: 7

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.