CT33628

The Granite stretches of Xara

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The inventory keeper Xara has been asked to rank apprentices for the new term. On the desk lies a long table of stretches 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 <= 2703; 0 <= a[i] <= 1000.

Example 1:

Input: 201 375 898 569 186 941 231 501 637 874 114 472 161 965 791 801 968 668 925 573 35 768 499 478 121 412 261 755 322 352 993 466 232 579 9 520 837 237 306 271 59 595 499 904 816 82 72 246 286 734 665 504 977 985 857 587 235 994 638 536 116 230 814 907 839 536 754 298 887 294 971 633 195 103 382 677 623 403 690 435 879 729 747 286 513 758 969 72 336 955 103 711 343 263 174 135 41 319 474 769 347 648 289 348 967 581 863 594 623 792 123 585 824 713 826 589 598 361 596 776 631 994 555 665 393 240 469 138 929 765 680 502 723 262 850 716 847 29 448 376 177 682 846 122 550 418 712 728 599 400 96 833 854 639 64 462 577 577 25 460 655 738 608 48 399 843 466 360 96 915 519 564 747 15 254 565 239 954 10 809 997 119 693 976 932 170 179 270 184 2 802 953 470 315 19 804 811 867 471 751 458 683
Output: 8

Example 2:

Input: 525 961 597 626 428 302 722 615 465 745 23 133 993 422 27 685 491 504 33 84 630 23 377 806 544 294 399 843 872 945 6 884 808 954 451 326 217 990 87 188 195 309 694 851 459 966 114 180 416 212 121 764 327 897 423 577 27 692 677 261 401 163 993 60 325 306 671 738 762 408 607 290 762 56 927 292 646 529 885 980 68 134 747 667 557 317 518 967 101 418 665 15 731 540 81 682 533 819 920 292 663 700 520 196 458 287 899 731 730 866 875 579 194 835 730 651 652 284 151 1000 813 607 387 963 372 498 162 476 848 431 988 779 271 109 718 730 106 633 52 298 178 376 543 643 954 645 457 944 958 878 532 935 835 388 496 42 440 468 905 974 851 742 637 817 197 156 929 227 339 157 938 788 162 755 393 381 715 281 802 136 348 135 505 813 317 840 453 853 452 912 497 22 127 804 619 776 311 794 687 76 913 397 572 428 8…
Output: 12

Example 3:

Input: 1595 840 754 899 725 329 858 917 779 452 3 521 919 824 891 181 810 806 716 500 994 52 417 470 356 631 738 644 868 141 608 142 567 283 529 837 141 360 499 568 646 561 924 334 446 78 476 205 592 973 605 910 794 533 290 337 586 768 674 979 722 670 478 751 154 479 383 404 618 447 312 810 771 483 231 908 941 758 836 995 507 497 925 638 253 76 265 459 464 789 231 104 242 944 686 341 758 337 503 177 152 54 884 516 519 585 10 192 577 948 104 77 877 966 665 894 707 897 694 131 241 861 807 301 546 682 971 827 466 825 491 187 298 351 319 558 352 758 525 569 781 270 906 933 19 384 917 918 589 32 385 719 138 84 94 426 796 56 621 700 394 707 239 913 91 727 850 485 933 669 323 535 68 661 871 81 864 851 405 523 268 556 5 351 655 668 307 286 410 481 99 357 991 518 444 403 389 10 688 436 65 508 48 681 292 5…
Output: 10

Constraints:

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

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