CT35072

Galen and the Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Galen found an old ledger of windows in the boathouse attic at the windmill fields of Gusthaven. The margin notes pose a precise question. 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 <= 2305; 0 <= a[i] <= 1000.

Example 1:

Input: 518 871 259 894 757 634 145 617 473 892 11 791 253 481 61 245 685 913 39 82 886 772 86 13 707 222 925 314 230 716 978 841 632 75 911 364 179 862 689 945 833 634 629 415 33 303 583 868 769 139 814 90 995 123 662 796 934 752 562 798 727 948 802 713 605 910 799 346 153 82 450 959 515 258 245 325 883 757 111 388 146 105 139 767 941 413 225 911 245 913 787 197 68 104 161 267 321 346 718 658 460 14 780 537 247 651 555 688 688 990 954 330 338 366 15 548 125 352 537 427 945 15 811 916 613 609 446 775 857 331 137 362 388 494 259 609 653 994 582 958 969 681 790 366 182 903 514 942 580 263 245 196 689 800 803 145 314 635 147 761 967 675 939 782 56 214 692 334 418 765 858 719 340 609 709 448 738 867 196 641 873 202 743 350 315 727 848 760 746 364 603 958 762 50 749 792 889 212 289 611 167 878 182 63 3…
Output: 7

Example 2:

Input: 309 604 298 183 139 922 136 724 431 586 879 446 487 228 158 978 528 264 806 229 112 991 584 266 389 34 259 215 79 106 607 105 45 613 193 88 518 526 435 388 410 992 483 346 706 180 256 432 269 980 905 435 80 50 738 295 563 966 506 711 826 985 973 704 448 317 19 532 738 415 921 852 921 365 357 418 631 80 701 420 723 944 161 536 781 405 701 455 934 914 174 841 57 453 716 236 448 271 218 814 291 284 268 759 381 816 487 432 605 744 259 432 355 827 457 879 796 927 123 261 926 448 884 792 176 958 695 844 182 259 171 759 872 804 724 422 956 89 741 27 390 726 470 898 149 480 695 781 872 268 196 567 737 897 756 772 467 350 10 459 76 981 114 871 545 511 693 245 120 73 57 366 367 341 581 493 733 530 145 405 659 129 812 736 448 446 511 753 548 246 838 171 637 301 898 949 56 807 331 500 975 422 303 36 1…
Output: 11

Example 3:

Input: 386 106 557 469 531 469 505 25 575 528 15 747 250 847 383 703 652 152 624 419 200 760 498 51 365 427 134 608 460 481 643 998 182 178 890 104 384 881 972 636 21 951 870 920 271 640 820 598 955 968 863 32 877 136 327 762 20 370 818 615 738 428 908 87 302 441 474 504 615 89 527 942 183 695 914 247 563 401 494 684 994 184 187 306 328 966 981 435 631 195 389 335 433 459 719 196 417 881 338 373 58 695 8 627 342 715 403 71 314 14 157 733 843 105 497 974 242 988 711 596 485 60 993 745 367 420 394 134 188 501 816 135 284 521 348 279 130 658 836 88 375 356 452 818 767 11 917 77 343 271 481 0 503 233 801 362 438 527 412 120 579 925 807 975 203 390 227 784 239 288 708 4 617 663 40 621 855 906 440 324 134 461 246 916 940 557 236 984 715 305 138 379 650 19 356 323 878 555 892 107 787 252 863 879 721 382…
Output: 11

Constraints:

1 <= n <= 2305; 0 <= a[i] <= 1000.

Loading...
Test Cases:No test cases
No test cases available.
Galen and the Checker Stretch - MEDIUM Coding Problem | CodeTikki