CT33212

The Windward segments of Tara

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Every season at the desert outpost of Sandspire, someone must rebuild the damaged itinerary. This year the task falls to Tara, armed only with the segments register. 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 <= 1496; 1 <= a[i] <= 1000000000.

Example 1:

Input: 351 605520557 427108436 688831080 618874322 633410336 771052867 187895627 913270931 113383170 197805343 41296809 560934485 552834 814841664 869405562 679162582 45037671 360002684 205118694 786458815 84208375 812937576 658904428 285362321 501261087 9542067 76966108 329739951 24183714 623460165 451073001 695278757 465299133 307855237 901403643 996413629 875204918 280490670 972719191 841188905 592121854 244095790 97319587 662546837 965070193 947299078 425125190 696135317 422464825 777621228 813506191 820099162 633406904 439953108 192918242 260915587 939632211 552791385 648589531 822222293 74294147 492181409 829007744 222645292 499594961 100664684 953892130 708883529 90729275 548771291 320795629 62125530 656161908 158326808 621545745 205824487 645351460 743416536 274657791 849269685 302540249 …
Output: 7

Example 2:

Input: 775 442786833 739427134 578867658 108193081 975040672 334220545 709358535 257161517 448455625 808278461 957508213 930210697 871737663 747045592 958243699 492618520 744362655 500077912 614331768 113495512 739338926 788220133 438777497 379165866 242841547 763741771 842776956 444633291 661875702 767245316 248765436 129257265 264201226 59774112 245594524 813631749 550334710 341989673 577333695 881509267 783763539 946072259 660989726 144801594 488402429 981041282 824287643 968885078 842611426 959019623 750925130 507757244 178000970 668888057 793375502 632149156 963726545 608135683 692648813 658412074 28086589 433171178 867416839 900337073 506816687 152816649 72153484 724473874 626375471 912050159 511930522 873638547 840252918 854050788 719647164 879125285 366906231 231139693 629600592 194026057…
Output: 8

Example 3:

Input: 897 773144975 657224639 246915880 178413757 791591103 901507237 435174908 417572394 762601592 104908489 767667738 394171082 650250976 247259303 152720370 958690139 298640533 616629704 653116720 468254144 31070151 679909274 629487666 504246813 794392842 318954901 462368851 253942756 146781389 395589407 99469238 536725699 409562299 645279851 422436794 543634196 267199191 312873537 570131424 817772426 621056009 982903235 221985694 583874608 82716038 163401260 597731127 995251444 781712614 265876006 447388792 301573018 245305336 606989155 650368388 221795869 188688340 851156765 781781177 391219165 547831517 338608243 126174714 635602534 240391832 386427941 130525740 391601887 109882697 174998137 479118344 335636129 536923460 703176897 353588587 6802662 974643678 351372649 189636964 971211434 9…
Output: 8

Constraints:

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

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