CT807

Forester and the Even Minus Odd

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

The surveyor Forester has been asked to plan the beacon maintenance rota. On the desk lies a long table of lanterns 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 <= 95; 0 <= a[i] <= 1000000000; answers fit a signed 64-bit integer.

Example 1:

Input: 41 305647356 56512067 655372098 523896994 315047457 605423716 633585203 755835381 60181778 368553980 542202250 546582940 737612701 437136987 284615904 857286685 618464594 221113640 105406594 800266520 668201236 599530331 993254050 109042631 222648445 781666359 739543475 321540167 11564482 618557262 470539314 585050094 953070029 514321563 82892344 988229460 463677903 836270691 791993671 132593066 831845971
Output: -172043679

Example 2:

Input: 95 435579994 483344194 602959229 151329392 741086556 345960208 752420431 834521800 605779317 307936718 979230138 290619470 260647207 397341848 878713929 210479628 807081701 733955081 682449500 955343157 174418898 850944508 795656412 476372914 146261832 841499042 576595803 499629841 199570504 683329400 252609822 703639770 322421526 156215044 715704374 983863908 352770836 616193452 887453029 911563069 353108199 180278979 630329058 898410644 134859432 715378558 43798759 42057063 678576495 345549604 415031873 128227971 331663069 464528116 352006030 109820660 321458375 663071249 536661572 97695556 856255912 828910632 725615780 959935419 806840199 286846844 994898937 552963266 807836354 26610347 434880609 922641662 893288232 505553884 351278629 720489236 182198246 237237821 174836185 892910340 868135966 177426134 657223102 586684308 815784121 729560322 869457683 640100301 852954169 975860402 66277448 565338547 234959725 273969256 891683084
Output: 1489168716

Example 3:

Input: 32 339706227 67400374 752659437 993589891 675873126 421375573 399789577 498397728 872981226 850247837 733072580 441669470 555731390 835384358 321671941 785012786 464104788 931976194 764854355 132196571 421359068 908390616 458177150 819884280 683483619 980188166 774873731 25466265 974509862 843010077 464110573 593909321
Output: -471140857

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Forester and the Even Minus Odd - EASY Coding Problem | CodeTikki