CT1091

Dino's Moonlit Ledger

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Deep in the mushroom groves of Fungaldeep, Dino studies rows of barrels entries. One clean number will settle the guild's oldest argument. 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 <= 49; -1000000 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 37 184425 -804968 55814 216486 916482 -193640 109503 -933823 745632 640047 -864255 645541 531618 860067 10426 143953 -128316 15734 571423 -617111 511104 55873 569795 -902298 81550 938114 601070 -866231 785691 914322 559728 770766 -513042 253519 -738730 552802 699828
Output: 3000593

Example 2:

Input: 30 -16313 154995 -666219 208148 -989157 75903 349138 227241 700901 174806 -796472 -661534 750508 -366223 -26194 -524054 -114860 -633919 833535 -749779 896212 -283180 -202654 237358 556176 -594247 -535148 -62727 -714657 84495
Output: 2737513

Example 3:

Input: 21 648385 -330156 242376 -409456 510265 -509455 863358 825297 855208 -478295 -783919 194405 -380530 975335 889095 -368665 900977 -218321 752857 -261484 -413634
Output: 4665233

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Dino's Moonlit Ledger - EASY Coding Problem | CodeTikki