CT32207

The Starlit segments of Innkeeper

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

It is audit day at the thorn maze of Bramblecourt. Innkeeper spreads the segments records across the table and picks up a sharp pencil. 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 <= 3928; 1 <= a[i] <= 1000.

Example 1:

Input: 2870 74 88 324 270 668 101 505 352 244 56 257 927 694 991 772 636 776 772 177 685 394 302 102 373 808 660 766 507 607 511 639 708 271 127 94 922 487 501 755 393 326 488 205 506 857 21 745 977 111 385 20 746 608 633 146 242 77 223 494 476 659 259 105 543 66 120 185 424 994 449 248 496 137 986 84 582 481 256 194 410 558 507 636 830 955 400 170 720 558 400 881 669 434 507 620 221 585 660 962 664 127 20 721 647 544 162 999 444 337 200 760 553 276 718 219 195 994 283 316 79 515 189 852 178 789 927 268 484 16 593 252 996 564 737 809 285 843 156 201 164 115 619 470 580 658 927 583 207 30 435 646 351 156 195 220 428 746 870 303 461 662 267 870 143 922 538 501 323 712 82 41 767 26 370 639 325 342 213 260 391 289 347 726 881 793 649 893 783 234 739 149 651 393 769 401 976 80 445 700 149 504 394 850 …
Output: 11

Example 2:

Input: 898 9 120 392 796 790 236 607 127 697 5 861 528 510 956 180 774 700 829 78 761 402 882 119 224 51 504 258 342 52 129 94 138 639 825 176 922 114 867 702 846 760 662 774 16 135 42 939 443 647 474 707 651 147 977 133 886 770 549 693 479 531 24 379 400 16 978 812 365 787 495 265 502 790 190 10 18 976 98 814 219 252 936 952 589 446 108 56 948 594 35 2 718 28 339 290 776 390 616 80 88 428 643 306 262 404 569 328 213 499 777 31 466 193 166 399 659 370 923 796 718 703 620 52 718 993 867 354 185 764 790 702 316 333 731 754 153 559 781 705 865 943 503 892 641 772 150 803 825 49 771 441 164 302 805 319 99 46 265 447 914 876 573 381 60 935 510 905 348 571 663 30 929 978 833 959 295 487 576 847 428 900 165 732 269 722 50 185 105 685 69 560 406 574 151 923 942 845 271 513 741 970 164 368 793 421 444 117…
Output: 9

Example 3:

Input: 3486 180 937 273 679 124 178 141 658 87 375 370 701 468 73 117 978 885 228 461 924 266 7 347 84 393 564 945 725 656 836 739 45 527 425 650 491 155 736 953 537 632 647 749 461 407 153 380 73 32 731 148 345 481 806 555 213 362 471 62 937 834 985 932 556 896 401 778 733 531 694 256 373 418 546 261 504 149 110 957 266 231 873 539 382 460 383 988 33 129 64 98 577 629 943 764 358 751 958 522 857 836 280 525 453 230 807 502 646 671 41 491 936 831 828 159 291 566 135 781 112 567 659 219 520 845 493 936 530 412 51 725 59 176 386 716 439 1000 472 760 16 994 424 741 814 588 389 981 580 165 408 243 435 642 416 380 992 844 295 227 727 740 344 23 987 817 364 942 347 283 927 52 294 905 442 37 405 494 127 156 118 918 480 448 556 130 47 635 455 739 579 159 191 147 322 280 612 68 359 481 789 754 30 999 137 …
Output: 10

Constraints:

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

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