CT935

Quartermaster and the Starlit coins

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

The valuer Quartermaster has been asked to tally the donation drive. On the desk lies a long table of coins readings. 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 <= 53; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 1 -180466
Output: -180466

Example 2:

Input: 39 -961695 -709629 -432242 -767367 -174701 -158233 -568065 -338248 -791179 -572335 -923665 -138926 -566211 -587842 -590018 -14141 -862532 -207039 -629910 -900918 -871269 -821619 -967328 -40139 -219234 -1650 -852851 -712316 -481283 -356878 -160360 -42844 -238649 -300244 -660491 -818018 -609418 -913783 -237585
Output: -3396517

Example 3:

Input: 24 -300506 -418960 -789033 -562137 -235063 -806068 -504904 -86040 -772260 -278561 -964234 -176191 -354966 -239884 -802892 -678194 -451824 -628819 -896262 -259498 -949921 -817507 -3323 -455799
Output: -1617530

Constraints:

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

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