CT32037

Last scrolls of Dev

MediumL4 · Loop LordAcceptance: 0.0%XP: 35

Deep in the fen lights of Will-o-Wisp, Dev studies rows of scrolls entries. One clean number will settle the guild's oldest argument. 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 <= 3737; 1 <= a[i] <= 1000000.

Example 1:

Input: 695 584854 935273 203222 90276 433140 156822 431915 415640 235525 343635 833621 494784 357320 75243 546614 837787 547280 218745 150349 949254 81430 183993 783172 972430 969196 303208 624880 547543 62502 376912 764325 528048 468777 745908 4975 892118 676014 492279 285867 900399 220820 183660 392266 266559 572481 483135 507548 586056 289073 542877 713316 701317 98913 53806 502810 382541 799517 684853 567669 508844 863840 695869 249681 131978 649159 573518 316350 991240 508074 58428 616893 32829 271456 686574 586560 560046 810379 566663 752579 589644 312519 630548 576555 355085 549901 190075 42117 911071 719942 823968 104914 45855 269850 526383 613866 66054 992189 849579 972007 648899 841945 29466 222582 811945 414233 895869 425130 462362 936993 875237 503680 384366 868562 523627 248655 31764…
Output: 9

Example 2:

Input: 2548 966203 162096 389002 931757 673480 912263 216065 76725 949370 793839 361032 417262 964425 692326 98146 612314 99603 698142 611775 657180 919834 648320 232132 21670 731780 131513 598840 546278 786950 569953 187126 545635 635429 106526 938773 856747 425159 406096 379402 801285 932027 632229 910403 446480 161829 510086 962222 59401 91302 9593 821995 364314 601524 845259 844090 472038 979207 519301 629161 938348 161270 209004 321349 813647 616456 611705 670605 217021 729959 771835 271329 248121 836196 299561 624121 369458 234017 116087 388476 6747 689624 382011 871264 490577 348103 113290 505534 310354 709092 418499 449350 881446 905529 56151 226360 601775 975153 849316 561500 705761 689771 175044 941713 586675 903816 761944 24368 245649 17274 819561 758974 114853 407324 159939 793802 585…
Output: 11

Example 3:

Input: 1181 912036 500431 934482 409643 574225 246080 61468 47408 719659 33086 473413 803041 763631 365772 630377 852940 374046 797037 814924 735507 58399 736187 19570 230426 822069 721607 12838 844302 295823 678592 241295 284270 377049 566988 932509 996312 529824 207372 323512 270257 831945 787464 232984 264662 202387 941432 74523 914696 595006 24863 585153 786796 340644 735300 995529 332124 460875 972010 598812 878445 172120 919935 889394 228952 231066 614522 652189 719682 467077 608746 33588 454238 630005 493781 953223 475081 829082 697253 678724 944671 172092 397466 669521 864826 115147 192701 187978 406827 822172 499705 49650 384485 30773 192467 878714 424874 287335 899223 152242 391840 787747 709099 605589 672581 809980 537736 706993 417943 270432 769533 916001 700643 557365 193094 804592 8…
Output: 11

Constraints:

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

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