CT21943

Dora's parcels Even Minus Odd

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Caravans arrive at the eel marshes of Slitherwick with crates of parcels, and Dora the paymaster must account for every last one. 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 <= 518; -1000000 <= a[i] <= 1000000000; answers fit a signed 64-bit integer.

Example 1:

Input: 139 114663610 328507087 933511410 151744549 47156519 801027789 384905177 324966592 375005748 924744120 86642878 132029222 302817528 182642967 863723003 636304275 5879447 63250213 438505399 305474185 74102673 224935475 55219709 174365427 85654370 787168897 722457183 436492887 346530928 399246267 411869902 415900503 158511122 980495278 805835582 982333377 690722197 645552285 106436201 540283030 891673713 613335998 874094198 550606457 838960898 851345146 485002204 266804549 635283825 571255232 487654180 187137564 659838477 312015540 667273178 828494240 529211989 256279230 74518995 349253347 258347048 160146811 992612706 673983336 148993131 671726443 207094316 706203798 431929445 628192160 685947006 597219355 8269029 553098005 611041015 516019615 798278768 800716512 360045548 38192571 40123999…
Output: -2120875242

Example 2:

Input: 263 386025745 991860636 711469018 164069352 819923052 690665367 48017456 552686444 355458120 444119401 850231207 723740948 777011296 252990590 796100223 855836182 736647612 592442964 164060551 565650312 722253766 65569770 600426335 69360578 586825095 114388256 291309524 425144748 529190727 509386429 394496585 163212686 651541058 802494806 439881364 252466298 142824617 691669265 243582239 155113909 131286235 683611777 690528007 307307594 72635535 105814360 579645104 81275757 589407713 2345664 237488910 499498742 608995440 871819642 909665461 339051734 937996266 361434567 753832235 949649247 757734902 793944480 577610906 136155709 738744986 271380815 563857081 900312703 420625956 275347569 479372346 314456162 319030881 253314568 273486149 459172457 138251576 175748942 112631003 812596763 675…
Output: -252108584

Example 3:

Input: 254 77448124 26697428 523535087 79619040 793129377 378913766 737339363 967662153 936886974 383314855 939888777 84934233 451241238 518049391 364342503 861386264 806574582 139603455 231449918 485352011 -188655 523545260 590843057 134573103 282483887 503270910 391075722 952054960 104345561 172390794 318998108 268181104 69839063 926212914 840663165 362955679 947700936 617636670 70052698 557026127 247664131 881130596 228280211 780341087 78775692 925039434 853353746 200514931 779753410 425022235 255422263 933404596 833411821 825065774 453236395 525236384 354669719 135026218 585399675 8401032 146933943 35226467 795861016 204405428 253934129 88968884 497893703 492243801 29381098 635605017 625708339 941154272 171714120 280550914 198983207 372873793 625109894 758189156 868074323 883660120 123800053 …
Output: -2804134346

Constraints:

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

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