CT738

Last tickets of Aria

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Every season at the ember dunes of Ashfall, someone must restore an old family record. This year the task falls to Aria, armed only with the tickets 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 <= 48; -1000000 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 38 17211 199990 723257 -555750 -304801 33494 -150476 323487 470490 -141173 743426 -800173 -125973 -782906 616754 710874 -540722 484098 754173 931188 818774 1504 846579 -953463 516340 984039 983285 -355316 658905 65589 -617024 18337 965338 -685601 -755050 -425215 66362 590279
Output: 6043566

Example 2:

Input: 38 -314948 -702616 -45929 377107 821212 612657 -340650 835772 705691 986329 321102 -717510 -978262 -312733 36463 -697666 -140856 173924 24606 -936474 -855205 -315223 875205 -902479 -579409 -257501 647892 161441 -936580 530411 -820617 918871 -415827 132211 -384894 -958194 -742824 998889
Output: -3051046

Example 3:

Input: 36 -532179 -643686 528560 387453 547995 -603920 -698489 706547 -623106 252010 143324 -1357 450222 932910 135934 -165228 972536 -684237 -719668 619583 912687 -956164 246416 6861 -155096 -422809 418185 624072 -459639 -710188 575972 278812 912628 -197723 58524 112072
Output: 3179798

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Last tickets of Aria - EASY Coding Problem | CodeTikki