CT27823

The Crosswater Largest Step

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

In the ferry landing of Crosswater, Herald the valuer keeps careful count of the readings. Forecast next month's demand, every figure matters. Task: Read n integers and print the largest absolute difference between two consecutive elements. For n=1 print 0. Input format: First line: n. Second line: n space-separated integers. Output format: Print the maximum consecutive absolute difference. Constraints: 1 <= n <= 974; -100 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 156 488964 435753 285417 68147 978556 16841 793619 198740 174348 179767 838599 871484 252807 713680 641469 181729 818108 865809 899232 198076 769870 44605 993338 408576 455870 374464 675823 188643 191893 585489 475997 763761 283921 599492 569026 190285 98567 681997 980921 313911 702984 338205 874004 469452 724546 156796 434797 470657 430415 708792 912675 904954 283432 172921 848305 232255 629974 393120 788255 538988 327697 662603 925503 62184 272723 207766 204188 533447 857648 743646 911925 931513 26037 989354 902468 819565 432611 977664 45888 454381 309280 161935 337105 311430 612904 447807 736087 291959 114326 381232 204482 29089 613713 433357 957134 244785 511881 984171 534541 295718 11839 974734 606874 20106 870516 773611 638063 715517 108268 297889 582550 994321 998507 821973 604284 740391 451792 30036 235888 78081 653561 441160 826469 662028 828785 137642 867870 12949 748517 751210 336719 632662 464700 805894 654006 142143 448899 990718 508259 866644 804228 801822 687794 563677 533457 13441 74871 911408 846606 697967 137671 237247 920906 650838 30351 338444
Output: 963317

Example 2:

Input: 502 505679 104837 409694 244289 348027 957265 135470 645802 284103 578976 657256 451529 730983 264066 182539 146282 655309 534182 601374 222214 192431 703247 956281 584398 252728 248334 384846 897258 945282 845093 19789 506369 311078 208690 382581 700013 872870 362699 13639 368594 809702 484796 539984 852111 32409 358850 704839 194497 333407 726359 66225 261428 842103 409992 924875 965260 845888 64444 353357 650987 382266 557503 503179 885429 653474 980798 946321 311105 345815 132337 741656 23728 845213 942730 692716 23011 720568 530023 559244 926201 476216 915312 840566 818163 868627 915092 894402 668078 430874 263202 739233 593533 115883 414116 760294 818117 147368 713444 2704 738997 461078 701839 392673 180610 50313 536946 228380 128717 980539 7722 806556 612756 440631 430245 390538 572659 676164 47551 317998 420849 848911 395794 293085 203152 523467 267107 762572 215300 962857 751762 125864 36408 751131 647845 787420 538100 178992 947837 821757 858882 227081 650274 804704 32039 945511 638680 826020 908111 950577 502317 812950 621992 672963 565807 423843 999374 103509 735318 246903 39239 944473 133426 880645 341570 448762 485950 366498 654384 190948 289843 639651 458126 716679 668001 125881 309612 908151 443992 622302 11854 354245 442528 158083 350021 286511 36967 204268 810337 183848 505714 308336 484444 426896 941825 998915 20150 489161 723821 271123 190779 193434 269361 38286 94940 350853 819686 687099 198975 308825 337421 880229 769839 324254 308536 603849 102177 237818 754969 641993 631477 989878 819718 494411 427812 184804 331380 227347 272914 534330 202629 460810 552537 106088 566559 369631 106202 264263 236884 929986 317244 57928 825233 686560 593586 230759 380875 888811 647957 364280 498306 678342 361606 627306 639716 832713 509188 139231 226323 540222 793205 452033 895810 777797 896470 255824 736824 475510 539568 575429 94321 999834 921918 925366 632211 931605 250219 201397 101816 907154 777872 160605 842349 36516 845369 908105 781881 115170 88244 450812 853695 552203 244444 759324 365109 789678 291185 941443 452902 254971 809168 204991 810141 728237 451852 499437 680705 269735 731416 400912 265097 443152 259375 14449 208854 733745 306175 435921 705454 241498 104829 735568 384296 145170 416916 796424 825739 958302 220876 420633 335217 570244 144750 179387 971858 535162 580455 594294 449256 233447 439014 504887 708518 391625 960391 496407 36398 482030 886906 130747 819045 676616 378295 554051 10119 433485 807064 73252 78503 151660 284428 113362 641906 42726 566386 41916 545278 327568 587127 15136 806381 922914 45721 990998 855824 687475 345029 705754 733842 952374 349110 824629 261875 902268 893021 659495 541545 750835 556852 78889 944959 421132 240641 980656 551326 366647 208512 179401 165175 27260 457307 950073 7139 6336 212908 409145 724690 112510 656076 74236 838158 417656 749560 752586 390972 716065 376474 281338 551430 958892 186444 861317 544667 234402 494619 37761 338022 249445 561360 493541 681116 366661 989733 22459 169936 556825 943420 461506 287299 33439 988725 103779 283032 366966 167963 983381 78529 192482 815661 90133 134477 777729 907513 983250 516407 592738 185157 481232 476358 648133 677547 362508 625290 450794 670592 649476 548081 275669 412248 508730 860512 811049 514866 61111 329544 598466 760602 140798 950739 707398 987897 514644 927067 528619 148752 375145 540281 580603 11960 173237 73255 985897 253063 64431 172071 703802 444281 374586 991386 283798 937851 647755 739418
Output: 978765

Example 3:

Input: 161 370569 417029 544132 241626 580931 35287 116103 39374 825330 669267 149051 296907 92335 346639 637705 751188 961871 354059 917473 856416 604649 46143 625243 4022 520592 81828 760015 363755 106057 522381 832095 875788 119318 759098 94786 735876 692848 418210 311047 512596 644336 389114 818189 432391 627312 512203 116546 193166 563561 315942 654020 671833 416429 777013 300001 233005 299381 633604 394817 916377 305084 830189 294831 45058 830321 70269 223432 562718 556077 13812 436013 165867 810953 828395 635544 620537 943672 661220 253276 953344 589111 337351 916063 174377 715942 337971 266624 244405 305291 938081 133074 854277 315824 762915 617586 140181 65537 158613 693339 197816 748842 604631 640771 646949 662492 304318 898707 448300 780011 302389 67561 250183 263672 367327 888269 427150 322965 912474 770476 625703 834866 410290 736203 318239 591422 749829 588737 352481 109284 104888 448031 175214 138902 199967 324863 697764 277513 929252 273085 983191 948266 99740 637601 751831 263554 954459 514087 354999 58107 74145 170419 978389 766662 309850 622442 978940 331135 168959 261506 326161 885861
Output: 848526

Constraints:

1 <= n <= 974; -100 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Loading...
Test Cases:No test cases
No test cases available.
The Crosswater Largest Step - EASY Coding Problem | CodeTikki