CT21840

Yara and the Jade parcels

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Yara inherited the customs house at the valley of Misthollow along with its curious bookkeeping system for parcels. Time to make sense of it. 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 <= 875; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 843 -613535 -678027 -163964 -272039 -274059 -587375 -850828 -100901 -481900 -676221 -802666 -586657 -768194 -85732 -36407 -115772 -536830 -236151 -1356 -891615 -213116 -978282 -288276 -59977 -763794 -822446 -152509 -706054 -908784 -499589 -684117 -430279 -670329 -572588 -126363 -996312 -748899 -560101 -162452 -512128 -613986 -815864 -504801 -45889 -497901 -372371 -845463 -185892 -337145 -152238 -513849 -969738 -105419 -685050 -210714 -436245 -988066 -827907 -12085 -45138 -690097 -162243 -454773 -181307 -16787 -733578 -874025 -477044 -379521 -13284 -925199 -106631 -551415 -6206 -219932 -538122 -498985 -538290 -894630 -120611 -586086 -744799 -918144 -591244 -694098 -453175 -978594 -74747 -980573 -869388 -746849 -377981 -674783 -376159 -339525 -66227 -311425 -548767 -760296 -174154 -587700 -3…
Output: 996101

Example 2:

Input: 37 -151302 -833901 -459346 -823537 -344730 -147333 -989188 -921812 -339424 -236297 -340384 -220919 -332557 -297478 -884289 -820920 -795675 -634154 -450773 -219167 -267038 -911179 -788749 -140111 -650582 -329026 -459840 -600815 -7378 -130139 -563518 -171558 -401359 -61189 -573281 -430238 -30516
Output: 841855

Example 3:

Input: 52 -611551 -145488 -895217 -960826 -11317 -446295 -630402 -118574 -265505 -855691 -674670 -941746 -245350 -534236 -71351 -460710 -499689 -695867 -262736 -426089 -693137 -413897 -760941 -197990 -296015 -896911 -188069 -25190 -818509 -231969 -818893 -174121 -319267 -151404 -329133 -73228 -745683 -643623 -279093 -168512 -978704 -150789 -650803 -269631 -95854 -116928 -545833 -88691 -366189 -67364 -859807 -628404
Output: 949509

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Yara and the Jade parcels - EASY Coding Problem | CodeTikki