CT30997

Brewer and the Coral segments

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The cartographer Brewer has been asked to tally the donation drive. On the desk lies a long table of segments 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 <= 2110; 1 <= a[i] <= 1000.

Example 1:

Input: 2088 751 300 400 509 357 423 336 912 143 771 652 479 695 567 759 726 709 843 201 874 816 504 633 214 991 560 239 348 1 827 733 105 725 169 30 475 64 850 593 208 450 245 396 253 338 383 138 465 137 421 415 92 179 636 323 334 253 737 466 997 216 661 437 109 664 233 807 129 940 777 974 402 864 319 704 124 725 643 396 712 388 82 550 861 147 906 412 114 870 606 580 292 939 145 555 460 76 228 165 416 650 750 991 945 821 712 544 739 491 917 597 951 123 43 856 710 12 584 404 938 345 325 196 699 30 849 377 45 218 182 49 228 478 944 54 316 392 759 573 673 376 839 500 316 316 880 892 577 602 953 860 194 876 212 806 319 777 936 366 413 515 894 137 54 272 868 881 444 603 965 951 665 199 246 202 187 65 225 712 417 634 923 620 467 32 703 538 803 328 889 550 131 879 814 198 149 946 531 213 518 257 864 877…
Output: 15

Example 2:

Input: 888 975 356 614 150 36 334 86 646 775 160 287 813 579 636 271 97 108 678 436 974 142 474 847 606 462 567 387 954 997 657 370 282 476 649 911 239 845 705 340 258 660 127 267 916 93 522 626 56 326 887 738 375 988 223 146 392 599 565 835 801 112 510 188 658 990 604 880 95 202 603 272 33 704 705 594 815 771 10 945 836 798 577 321 983 674 233 704 955 692 30 909 817 173 245 253 881 285 312 711 639 832 427 671 305 787 882 133 628 608 257 478 266 590 451 281 57 484 959 211 888 424 674 309 232 400 5 320 469 915 394 148 171 711 954 925 956 799 549 339 702 906 299 121 412 505 793 483 107 927 446 133 658 678 704 227 751 892 724 947 834 216 521 725 281 279 713 854 846 498 726 349 225 479 975 914 768 978 240 295 670 345 492 143 487 561 124 601 222 236 826 681 853 815 703 410 327 419 155 420 610 585 481 …
Output: 11

Example 3:

Input: 1994 172 54 765 991 812 398 80 567 275 989 575 578 349 287 228 495 93 438 55 725 39 380 62 582 474 512 300 564 402 362 240 8 571 470 852 872 404 337 275 912 580 367 791 187 877 963 646 187 56 363 792 859 867 76 77 897 188 43 838 636 305 670 297 864 287 261 966 717 821 845 881 441 445 152 323 971 981 811 834 724 707 925 565 704 443 20 652 48 183 813 461 279 163 188 527 299 979 753 763 625 729 381 634 5 100 355 465 833 112 799 694 906 452 639 358 415 371 657 696 265 74 221 942 232 889 656 267 127 449 641 830 176 318 355 567 365 331 885 255 794 207 248 680 764 364 882 1 641 284 988 736 856 638 950 606 743 580 258 122 855 906 65 548 93 87 509 500 969 535 632 708 849 919 85 370 381 856 49 851 155 445 651 698 803 619 600 1000 747 182 567 9 637 256 382 750 947 800 930 783 161 644 96 878 778 310 7…
Output: 12

Constraints:

1 <= n <= 2110; 1 <= a[i] <= 1000.

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