CT34523

The Solar Checker Stretch

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Legend says the vault under the lily shoals of Padmore opens only for a perfect tally of segments. Odin means to find out. 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 <= 2412; 1 <= a[i] <= 1000.

Example 1:

Input: 1093 325 195 303 118 907 1000 14 954 193 151 297 421 298 697 647 553 413 86 860 535 614 276 425 790 489 585 223 182 943 658 693 927 358 677 390 621 153 530 207 588 408 227 274 191 899 532 415 789 735 321 947 733 877 101 587 726 709 673 221 819 888 648 598 230 405 629 101 77 119 77 246 551 720 299 835 980 114 518 91 293 380 605 391 553 371 842 990 796 472 930 359 69 396 156 549 511 129 769 346 607 77 155 855 533 587 921 902 686 436 39 462 781 243 62 279 268 768 470 683 362 19 939 855 655 422 204 285 203 218 911 18 557 246 309 268 168 318 169 339 519 453 337 804 568 532 969 501 366 824 970 358 75 530 546 668 175 367 814 558 247 54 832 198 963 655 444 72 236 103 541 513 618 229 843 415 476 717 265 732 699 347 537 809 41 542 333 679 759 896 581 834 404 588 978 355 462 73 102 709 690 829 94 627…
Output: 11

Example 2:

Input: 970 463 394 886 377 152 65 85 660 471 734 253 637 866 159 775 751 266 676 792 506 559 568 41 749 874 66 968 560 894 280 894 146 54 156 344 451 732 861 751 745 295 501 150 799 691 535 14 129 219 982 914 903 351 938 298 490 177 138 945 526 707 34 316 95 534 242 174 485 4 504 200 1 683 296 598 401 86 426 88 48 544 874 786 8 720 450 984 207 745 852 439 419 371 377 66 438 663 100 678 593 314 504 549 686 146 216 848 131 581 50 605 885 507 856 887 951 814 444 555 123 689 216 621 365 21 634 674 189 343 341 571 696 205 243 855 147 400 604 852 229 687 190 530 158 628 477 305 196 974 279 568 403 62 101 929 248 916 94 53 534 4 57 621 376 314 881 406 185 809 662 747 626 754 803 672 207 160 221 375 46 639 753 333 568 621 787 724 351 311 527 385 509 927 346 282 229 27 870 329 967 596 42 51 752 353 150 31…
Output: 13

Example 3:

Input: 192 130 760 81 143 324 525 309 564 850 403 588 399 916 510 322 1 142 215 11 112 654 64 83 164 736 609 973 644 303 6 431 107 546 532 404 488 192 240 99 999 306 328 469 697 497 957 709 116 467 610 276 494 950 274 87 484 735 144 763 499 955 703 240 725 874 905 181 481 833 864 134 807 62 705 457 607 33 34 320 456 77 282 15 907 852 969 229 47 63 677 749 355 292 904 599 640 572 53 593 442 929 220 309 176 63 56 217 598 431 25 428 138 684 867 102 816 98 81 154 632 519 73 480 280 193 707 431 433 726 233 307 616 319 939 811 153 717 497 907 198 993 63 6 217 909 712 563 24 684 5 352 619 453 177 711 29 724 101 449 319 388 67 720 496 735 543 849 806 664 858 79 530 589 98 608 395 70 338 108 772 997 320 939 592 537 348 562 650 747 568 206 832
Output: 11

Constraints:

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

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