CT26478

The lanterns at Fungaldeep

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Tarun inherited the signal tower at the mushroom groves of Fungaldeep along with its curious bookkeeping system for lanterns. Time to make sense of it. Task: Read n integers and print the sum of values at even 1-based positions minus the sum at odd positions. Input format: First line: n. Second line: n space-separated integers. Output format: Print (sum of even-positioned) - (sum of odd-positioned). Constraints: 1 <= n <= 226; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 114 -21995 -214139 -440944 -580719 -697774 -792547 -938281 -655136 -913395 -767393 -169974 -300190 -378980 -486852 -916689 -652280 -463549 -697630 -624124 -492599 -895633 -57394 -904390 -905535 -367258 -626815 -461619 -153548 -798336 -191841 -475596 -829193 -902250 -617987 -806966 -664348 -967097 -33130 -677022 -35478 -780802 -992573 -840041 -572521 -169734 -720507 -1900 -493568 -584556 -562700 -354953 -229944 -437747 -915874 -467295 -637090 -850677 -295020 -458876 -560061 -294269 -226778 -653090 -374107 -65930 -368367 -574129 -274011 -104955 -109199 -810626 -105028 -513324 -700290 -811558 -587768 -930913 -812588 -540852 -628871 -869841 -561704 -812889 -353865 -629177 -266352 -241191 -408919 -277940 -513685 -870389 -339912 -30073 -672662 -672617 -651387 -256431 -33944 -670278 -307628 -5678…
Output: -4472115

Example 2:

Input: 17 -71942 -795946 -803298 -54797 -116672 -993800 -356056 -344567 -986409 -59975 -560480 -644982 -254776 -458696 -315784 -519030 -403430
Output: 2946

Example 3:

Input: 211 -148150 -277139 -412456 -208345 -522951 -285750 -434071 -984676 -933738 -777500 -285224 -172971 -517391 -696221 -73085 -197330 -515078 -201547 -117612 -372614 -977815 -780813 -312072 -491072 -573653 -433196 -409353 -878211 -121316 -215242 -487049 -852504 -83826 -426219 -812540 -137985 -593941 -3294 -429228 -317271 -267581 -766465 -470269 -35453 -830477 -978827 -438159 -202635 -778241 -784472 -434813 -33918 -271014 -997811 -99582 -404874 -328261 -398634 -489817 -169288 -879296 -808402 -973687 -113984 -199001 -250904 -775421 -423686 -373297 -553351 -210244 -362921 -817061 -737880 -233384 -13909 -952680 -386630 -278081 -400952 -734388 -356516 -426442 -189715 -472846 -180084 -603060 -248678 -690860 -369698 -241923 -808422 -849648 -371419 -702704 -824209 -723652 -334509 -799021 -597397 -590…
Output: -2153749

Constraints:

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

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