CT1834

Porter's Ledger of barrels

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Every season at the ivy courts of Vineward, someone must forecast next month's demand. This year the task falls to Porter, armed only with the barrels register. 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 <= 95; -1000000 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 16 -957998 -841714 -837923 -737613 -110122 -602054 -910735 -227111 -634540 -985135 -100002 -832275 -116969 -977381 -666320 -196579
Output: 1065253

Example 2:

Input: 1 -163077
Output: -163077

Example 3:

Input: 36 -54470 -76703 -906521 -765726 -748783 -32513 -2848 -355897 -867344 -963801 -493242 -347016 -151657 -347369 -422046 -636900 -591874 -477623 -110508 -720429 -221440 -226771 -269126 -986378 -810419 -774297 -21257 -946483 -41440 -751467 -687307 -683103 -162874 -138118 -610468 -301920
Output: 2358890

Constraints:

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

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