CT34420

Last panels of Tara

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

The council of the glass towers of Prismhaven pays by the answer, and Tara intends to earn it. First: the full register of panels. 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 <= 3982; 1 <= a[i] <= 1000000.

Example 1:

Input: 3053 803549 929182 92792 833592 268485 283653 369291 858165 785111 560123 296495 363792 607007 888824 866171 936227 687431 529605 241850 85787 889347 527953 384014 740608 534017 519242 655291 129891 288105 951447 525341 98046 430613 915731 282474 524182 80713 384122 12601 278544 731146 247519 304791 8862 676043 110814 440437 593209 827932 314113 878468 28046 178125 172139 526972 997193 491564 633138 678935 628706 198656 737193 548885 688694 400177 631536 778563 44321 809337 129565 51313 97645 877940 884351 513527 25786 438000 105550 297667 886743 605552 303757 741096 966318 906244 923891 375707 959529 315185 884932 770636 915611 630257 937901 520466 385954 192197 628106 864886 26902 386890 193213 74502 99337 522206 157304 542987 526861 535646 801670 667050 493004 995949 793842 838990 17918…
Output: 11

Example 2:

Input: 1643 773379 736108 828566 91717 8890 814318 138814 708992 267841 985398 762169 416602 803212 272123 248608 864451 427434 797170 693636 751180 332567 724651 310443 822625 966639 809931 519998 617891 863654 902759 762009 107780 283855 787370 387856 857977 583741 955646 127525 892659 163717 253701 765605 847761 629914 513975 642727 587603 235976 664887 986259 679586 397426 658227 965518 138914 867028 590335 70005 881829 675861 33877 634815 827127 677677 778169 874786 286726 569969 756565 566188 271941 605590 102854 787447 887410 823623 731440 503437 178715 306511 387066 157091 874825 345224 632908 987073 777912 195783 574507 840945 693014 780205 591325 677375 492717 755370 560404 1349 343517 837225 493539 441583 458862 579524 283564 174868 832437 815563 25884 522165 858099 200976 309367 11381…
Output: 20

Example 3:

Input: 2682 436139 874070 562494 189908 463725 830943 996396 322264 608415 4411 118560 870466 431962 740486 776099 547757 63110 685584 499457 476932 449454 809910 427293 658667 176638 648724 818908 280919 443008 688310 228992 990355 157031 583105 791981 536588 814981 457543 414722 171655 207705 83082 616391 796581 619351 602304 733078 692668 93703 762868 802924 889403 375859 711135 536129 780325 143367 19208 690983 70955 487735 460901 422413 207259 835146 703616 651450 982573 822553 887525 282694 920651 591649 605458 530607 733659 511239 178898 344023 919254 125044 371108 547116 406867 1468 444032 477049 136222 38717 323026 994831 289995 854282 89643 437401 717227 495505 595062 944142 789439 951742 632611 260486 850084 496043 703121 825160 276761 89665 267953 147792 271058 473243 34492 513581 804…
Output: 10

Constraints:

1 <= n <= 3982; 1 <= a[i] <= 1000000.

Loading...
Test Cases:No test cases
No test cases available.
Last panels of Tara - MEDIUM Coding Problem | CodeTikki