CT24123

Ivan Counts the coins

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Morning light hits the cork grove of Barkhaven as Ivan unrolls the day's manifest of coins. The tally will decide the next shipment. 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 <= 469; -100 <= a[i] <= 1000000000; answers fit a signed 64-bit integer.

Example 1:

Input: 328 307259565 903575579 680953790 421448962 818181832 81619900 113008541 920156571 570034530 889735637 845623425 535274025 5154668 238643829 289594863 854362843 265496211 321953902 873249313 904080002 834667226 604810071 181684134 453449533 303971114 146617393 528560520 985958345 313690108 987233523 473106857 95482908 272967794 789321996 369435841 914810518 203511633 486848843 914871342 215849592 574011230 726630009 7161928 204719909 233810667 77344555 389384680 653622610 412549126 944483683 231229586 858906578 392724685 104573285 454615123 571474262 463049165 18075065 782754893 850895948 756546469 825908913 299034120 352982093 552547359 619201164 408220553 42604574 224368629 514678244 347762933 1960235 660094498 666596647 428206363 284287836 471328018 651281058 819086468 755760181 7231706…
Output: 908449637

Example 2:

Input: 35 812396252 947114334 699379807 657653468 276658550 907100999 891216571 15191266 714291074 176923618 516007481 511003113 338037805 625153678 167010959 168511179 675956429 936114819 920954825 969958468 779516297 780662767 956333093 843804862 929976578 601523801 982768662 536868608 314076975 504341425 723503529 306554958 306044099 268848286 891854272
Output: 876025305

Example 3:

Input: 221 555665349 752941337 317462164 179226530 428276032 795075299 469300503 589058081 521142102 301907725 427168315 166513637 782020355 957631761 448687974 202478244 615103291 429434206 38785233 935838032 742251952 691829687 449445594 363902345 684953140 625849828 986680281 856726111 217364135 90136706 508573084 102339047 816263272 456193611 563313495 856213580 497573592 980712502 320157511 486390847 657967533 714375923 316761818 515135906 827298089 589752608 399826930 751908147 523783839 336607469 716004976 127478542 88373940 787909343 420919356 593396457 345754704 153317125 934146749 585802527 135417463 325267164 108723468 619480090 828270228 56531197 944303918 775832815 888018514 487514829 218052061 242551722 205728486 814954059 381848899 742468138 674835794 635697884 449397647 908710276 …
Output: 985647652

Constraints:

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

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