CT1038

Zoravar Counts the readings

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Zoravar found an old ledger of readings in the loom house attic at the otter slides of Sleekwater. The margin notes pose a precise question. 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 <= 99; -1000000 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 26 687068 591775 -541629 -691953 -964133 745828 376682 -410346 338007 -705078 298803 -666219 512175 895943 348523 -228797 -959920 72823 773849 -795414 661685 473352 917863 -162867 -288138 -665095
Output: 3706883

Example 2:

Input: 27 -777745 408756 938752 155075 -846030 -117372 -857481 281284 -918984 -70455 639066 140061 -816944 611079 65917 678039 118399 -947661 -220693 422325 43880 156633 -429532 -798555 605245 39023 310921
Output: -3103461

Example 3:

Input: 32 -615962 -268011 -597372 782701 -76701 -96599 -217914 -402700 714264 668540 186644 -788412 -776449 704986 -590492 -399664 -42048 -481930 287958 -348160 875014 197550 -752222 -930715 -793414 -560722 -294657 384174 410437 -14063 81357 120113
Output: -768645

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Zoravar Counts the readings - EASY Coding Problem | CodeTikki