CT25253

Tinker's stamps Even Minus Odd

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

The reckoner Tinker has been asked to publish the quarterly findings. On the desk lies a long table of stamps 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 <= 638; -1000000 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 176 -588881 -894729 705266 -333295 277837 783642 665399 116580 577071 930648 -311705 243492 -966778 -891789 -432112 -183928 -837008 884546 -567937 430632 18038 992630 803720 854197 -78738 -508969 648600 319598 645678 276471 85881 914623 -768776 824810 310695 896374 216200 -243741 -59572 674252 148797 -766677 959826 -112337 655272 -306392 166846 94033 -979540 382615 -695721 -79797 184341 -458251 682316 474557 318526 819591 -446029 -432966 -925574 121799 -877658 -342427 -729028 -172085 -484798 -575062 -96119 656943 -810370 744721 394646 -224842 551801 -888946 -306126 828738 -546419 -648727 -219694 -22277 667356 -612354 784872 -805311 750135 676957 -906681 737461 -667747 342641 749247 -322656 -823156 76568 268686 996491 -17373 786464 -108592 -806807 -103911 -821561 -635334 -958962 291773 286067 908267 -816768 -720246 448658 267741 -482698 -192313 465951 -337319 633349 795776 745195 449105 554096 885609 -416427 -598089 -468959 -440920 38757 37751 104514 639090 1998 -468271 -387554 -358972 -671129 -628049 770655 340355 -971396 235897 282972 -770898 175034 -285841 -422087 -137742 822493 99584 -311414 -469361 -992433 -538984 -265615 -467105 -494482 -529580 795730 8086 319629 114203 743958 569476 495494 -727618 -640621 -747426 -298 -804045 719740 -674622 710989 378404 684030 -739468 765516
Output: -15060207

Example 2:

Input: 132 81851 -717242 -676688 -86552 131301 187802 -974861 -88465 858752 -4695 -275666 -349177 -86895 796410 -889334 150636 -546046 -338145 -209661 -923901 985702 982046 -76326 803125 -425510 481020 -837207 -785761 -900940 -475923 -119165 -232230 499353 812000 -230754 666009 39503 -677042 251064 -871950 -336391 -835051 488464 577463 -915752 200730 -415977 -677506 -727779 -836729 -649386 76533 794969 -98228 800222 818345 -673852 49054 -609059 -969456 770181 -642927 181069 603139 -576227 -586360 -304578 797119 -236748 -580329 83114 -721391 -236278 21855 100440 880324 -127529 -142761 482715 565160 -458265 -101354 -50493 -582131 -880470 752510 -85464 -955075 759726 -74858 -690405 302940 -180137 -806908 -132568 -853695 756366 -198513 746785 -789557 30076 -830214 -612138 717009 -184523 -465745 -66493 468744 -897103 -423828 968582 -344636 747757 -193707 -527249 -198697 -665721 113652 429186 450509 59751 932554 -136788 771621 434618 655857 111585 823036 322845 -548881 130899 -220634
Output: -1806498

Example 3:

Input: 449 591144 -876064 923325 834634 -494323 2394 498111 -21783 620736 350016 -628528 91218 -667644 19893 552417 -856184 -444847 -700605 -430741 530343 -340118 -935462 -299371 -890572 -192406 -319081 -557938 -318347 -737712 -959876 -608124 369565 602266 -526106 -488582 -640579 -361303 226276 393301 -338717 -263765 412735 -496107 -419153 402738 -705710 534021 959969 -992480 713661 -695162 798476 -197577 -565173 507511 -463951 228747 -748397 950399 388907 236988 803955 88118 931904 -929345 371443 -251019 541584 -319693 762705 -332559 449183 -703555 -289667 -655840 -909212 159301 759213 517740 -342099 986273 375929 -516252 590225 -682791 -162965 165972 634828 -659607 933986 -799245 -441123 533455 -355234 -999147 928159 688072 779642 242496 -939962 951764 -453074 -90763 245452 957767 402798 -41595 -389775 -789471 953577 919079 -673464 757358 719147 698207 -798395 -808304 -367887 22905 -911102 -951002 -2184 -116306 -850138 23567 -222303 -39795 -145850 -77147 969763 907805 549285 -660560 -354967 100869 258042 732280 956468 954361 705321 -230499 -442057 -25028 493030 -152850 197160 -532932 -621829 966373 616338 -55641 420150 500129 -973194 879745 -494442 477659 -347532 -750480 728375 -89935 -395855 315324 -184582 177085 272033 548957 976547 452694 124764 518775 206726 -977893 -315959 -530224 566732 -777972 990675 -763770 -296591 688144 962170 543836 155019 336661 796222 62579 244474 333733 -527894 -555219 -345498 566060 -76832 584625 466522 -719559 -266927 -115833 672869 76897 -552856 282015 139082 286879 982229 -573265 -298778 308663 322270 -78478 -788502 244975 495669 -302620 -813782 494026 932253 -728193 309408 602724 -94340 -743712 -163276 980922 -822350 -386552 -837517 -825961 -87474 506087 621581 138111 -814206 391861 327447 368270 865787 887120 273304 132632 644490 -605406 -618206 -826206 431793 -116540 -297177 -548646 784133 546116 -771417 -369606 999001 665355 851439 -920566 28645 856196 -593925 368729 -442869 -223233 -262199 474919 776716 -875193 856088 -809972 991904 -642153 -394205 16548 -606601 974320 602130 662886 932088 12287 172480 908276 230744 -288394 98882 167889 519858 -330935 234189 -513214 576406 532027 528873 -666588 -518112 368105 572128 37335 -127951 -889672 842770 238926 -42816 950402 90345 -373332 649236 -790171 765051 -437857 -188652 484179 909522 -66545 707831 245712 189316 -194470 -621918 -896828 -750908 -880107 106175 895360 176602 559509 -760202 -586204 28455 856509 -455123 217670 -665681 -775438 -842832 -516555 -909889 -568183 523795 -159210 -569246 219095 175976 -332290 145023 -503567 439753 -958949 19579 210588 -472250 386239 815027 -720148 92199 940614 -268222 -565779 98478 787741 -589127 586720 286026 916567 323438 -529056 -228216 923114 974805 900380 -760692 6400 -766105 201235 -762077 -445137 -232772 -154328 -459628 -871397 -267221 -517324 662867 244989 -443634 -787810 459503 -198331 -277524 -286596 666209 -92238 -558604 -431148 240834 -268395 -321601 -271903 -804203 889478 300910 -551570 326217 781940 -597259 769801 -659349 502003 -679390 -705067 -897473 -592738 -820461 -222599 360592 866961 -201937 -411944 662776 390751 -217836 -767495 301738 838167 -939083 -81292 -527704 -310607 -682888 -741112 78487 340874 932372 739890 746767 -757460 212678 -828074 349530 -20681 -636572 721795 -619989 -64832 -492296 111592 693403 -614774 -865838 -785543
Output: -8798395

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Tinker's stamps Even Minus Odd - EASY Coding Problem | CodeTikki