CT30828

Tarun's Zigzag Ledger

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Before the gates of the granite steps of Stonehallow close for winter, Tarun must finish the segments ledger - one figure at a time. 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 <= 1130; 1 <= a[i] <= 1000.

Example 1:

Input: 763 489 497 67 324 294 784 587 429 863 400 469 305 311 446 79 812 976 262 643 490 668 631 856 78 813 911 472 244 122 231 37 463 855 757 82 236 751 914 734 736 66 821 73 39 798 183 786 863 678 999 696 35 438 843 821 903 762 93 700 768 221 879 851 327 326 418 244 42 124 318 69 78 928 29 112 93 281 194 404 122 812 769 933 849 224 534 102 944 649 980 73 407 163 634 501 160 930 991 723 373 898 550 744 113 299 210 414 304 512 618 389 10 653 48 387 560 964 611 126 674 469 120 400 432 327 751 489 969 989 373 547 66 816 503 40 41 690 747 57 413 58 591 127 542 314 522 36 623 554 463 478 600 345 561 581 851 610 767 356 57 969 338 15 60 344 530 74 746 594 512 807 82 47 57 942 494 240 405 249 10 768 957 174 772 275 547 662 475 213 354 746 163 630 585 196 82 20 593 910 702 82 783 83 782 573 115 646 547 …
Output: 11

Example 2:

Input: 410 334 828 908 820 138 666 519 566 505 199 280 362 975 683 981 944 453 435 168 671 284 92 801 56 719 792 655 771 923 55 776 919 652 501 401 160 820 199 585 412 588 694 300 127 151 208 770 465 730 23 841 150 535 822 509 90 321 898 267 477 571 724 735 852 917 725 257 511 204 618 472 872 456 164 104 898 521 697 854 321 358 885 812 657 86 971 824 355 876 196 351 14 903 646 333 598 108 383 688 2 172 771 864 300 727 38 476 411 232 658 869 904 751 667 691 723 57 400 843 166 42 766 734 867 291 842 709 960 394 543 140 432 129 733 61 531 792 547 540 212 81 541 293 686 747 89 985 741 110 601 248 371 952 362 453 340 547 563 172 881 862 731 531 314 687 894 844 442 998 203 672 268 277 402 598 366 36 470 354 53 842 703 707 556 513 692 335 914 676 872 872 963 574 42 147 777 213 849 949 752 817 763 249 49…
Output: 12

Example 3:

Input: 844 167 244 833 457 714 340 613 189 128 741 579 969 144 610 576 161 999 656 548 452 965 486 4 92 760 139 946 487 872 639 148 541 670 498 105 373 929 446 283 817 793 892 948 693 450 622 225 572 963 491 352 219 420 226 506 208 683 388 878 154 450 699 879 399 584 722 276 819 369 763 999 617 447 497 741 944 728 373 962 681 433 647 66 754 947 42 631 472 62 881 546 784 425 408 104 239 343 35 730 282 22 195 537 327 626 576 725 1000 138 820 693 466 398 762 242 30 908 15 168 842 580 62 151 92 40 809 53 299 393 195 990 380 334 531 714 873 703 201 767 898 645 976 522 690 548 514 381 991 800 810 381 445 593 739 186 589 904 870 624 390 40 1 196 295 98 538 397 248 559 785 62 884 993 161 576 206 417 107 228 245 374 226 244 745 905 942 77 538 829 407 598 231 213 780 858 790 303 189 777 572 654 215 225 317…
Output: 11

Constraints:

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

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