CT33296

Neel's panels Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

In the cork grove of Barkhaven, Neel the log keeper keeps careful count of the panels. Prepare the winter inventory, every figure matters. 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 <= 1649; 1 <= a[i] <= 1000.

Example 1:

Input: 1336 430 851 321 64 346 80 692 897 885 354 824 65 978 186 903 32 33 848 305 463 945 391 132 345 328 698 291 537 716 517 984 563 274 940 698 151 939 967 407 959 515 923 249 602 921 716 375 929 360 859 612 931 120 432 918 83 698 720 839 226 65 701 784 925 41 240 657 43 54 804 273 288 266 729 637 109 508 259 966 634 38 898 93 417 806 889 468 477 6 821 215 189 971 461 116 566 341 147 739 731 472 259 564 605 467 301 311 719 629 229 851 73 687 192 594 135 851 546 228 812 916 450 43 879 188 412 601 779 851 500 47 746 195 574 392 228 543 491 301 716 815 139 573 635 179 140 713 737 853 638 216 129 637 187 27 172 986 562 269 775 802 261 453 92 928 482 68 546 999 783 469 295 670 84 525 292 889 91 264 3 408 798 31 966 278 367 972 30 102 409 350 540 623 249 408 537 745 522 358 390 261 217 440 997 337 3…
Output: 8

Example 2:

Input: 38 582 51 759 150 49 861 406 414 585 862 20 630 718 586 323 216 119 443 81 566 27 460 737 2 221 128 356 277 517 70 439 476 455 429 545 146 351 252
Output: 8

Example 3:

Input: 1500 677 543 866 708 716 944 404 872 480 355 835 100 485 173 772 361 4 144 814 155 117 932 781 913 962 223 387 618 113 882 531 994 728 391 233 478 19 18 981 138 507 694 627 383 846 668 622 667 418 273 770 135 257 809 248 171 997 25 175 644 434 894 693 934 715 495 442 518 987 204 2 337 97 316 121 180 69 287 276 559 637 323 416 301 926 564 904 6 670 768 533 288 518 483 173 177 255 333 891 777 121 804 485 858 179 474 916 489 189 662 453 93 175 904 349 733 698 629 79 194 186 694 382 420 852 602 695 31 139 99 404 290 7 611 33 234 239 102 336 237 735 376 964 37 950 339 241 64 899 811 415 256 341 707 334 983 567 430 675 839 530 377 178 40 272 60 163 815 701 832 106 100 51 431 291 403 346 988 489 387 467 290 529 781 29 325 692 673 224 635 169 519 407 408 310 85 432 219 29 38 831 174 218 474 933 89…
Output: 10

Constraints:

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

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