CT23833

The Checker Stretch of the Beryl segments

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Deep in the island market of Coralcove, Manav studies rows of segments 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 <= 1543; 1 <= a[i] <= 1000.

Example 1:

Input: 724 92 291 339 441 867 658 308 628 24 237 472 914 234 135 946 58 698 291 885 764 654 159 13 727 888 232 599 781 451 778 2 539 649 719 855 165 690 639 826 692 264 818 850 616 630 35 776 956 608 281 381 686 995 100 26 320 307 814 887 795 549 630 982 274 75 416 715 971 747 500 864 721 497 665 184 305 692 428 45 214 776 485 986 133 794 71 686 726 631 74 873 963 103 79 32 845 963 949 254 401 183 148 720 956 105 577 743 256 83 70 261 212 973 302 16 693 651 702 114 71 423 360 423 274 212 727 1000 387 706 259 817 697 919 948 677 644 907 337 769 770 958 989 757 289 356 14 615 487 987 241 193 492 897 463 552 372 282 628 114 882 74 724 485 740 526 723 447 979 483 525 483 408 397 836 55 734 150 559 257 309 11 914 726 91 784 673 57 713 505 53 232 190 324 227 330 551 919 383 437 854 539 286 303 572 902 …
Output: 11

Example 2:

Input: 62 175 13 642 288 800 686 43 740 984 983 551 738 903 795 159 907 446 625 981 80 490 571 365 242 838 65 364 770 953 18 751 242 335 277 158 766 232 173 633 774 573 717 671 120 599 717 155 884 939 749 646 329 282 97 997 473 706 420 474 805 601 364
Output: 6

Example 3:

Input: 585 464 719 881 277 419 761 221 565 899 195 532 196 588 215 60 273 39 143 438 73 485 23 320 104 744 969 910 791 963 566 549 185 652 976 830 336 193 795 986 282 626 919 537 488 514 637 699 625 264 756 554 584 192 899 915 966 932 427 778 530 45 684 106 811 790 73 905 211 690 106 883 319 841 809 953 112 596 934 489 53 631 693 594 70 566 737 622 379 806 584 334 948 953 870 86 82 667 888 711 29 618 935 693 594 241 707 260 41 375 645 960 746 995 65 128 90 100 554 82 869 636 841 747 553 977 338 724 448 181 874 765 749 311 468 393 334 409 738 424 156 288 684 135 961 714 636 249 471 465 882 281 854 936 992 907 383 863 23 95 892 370 532 482 712 770 228 265 704 54 315 899 854 726 261 692 335 920 739 261 597 151 644 465 652 451 264 390 843 861 70 952 854 477 54 819 975 384 763 160 397 163 8 921 50 294…
Output: 10

Constraints:

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

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