CT26706

Navigator's Even Minus Odd Ledger

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Every season at the lotus ponds of Tranquil Basin, someone must reorganize the archive shelves. This year the task falls to Navigator, armed only with the barrels register. 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 <= 520; -100 <= a[i] <= 1000000000; answers fit a signed 64-bit integer.

Example 1:

Input: 400 104392699 298426553 360322108 438231467 804913508 100959062 4366796 407148962 150962321 374446762 251993736 869858656 660700910 955848980 878027907 585077707 15395478 333272475 632397316 742891063 669603105 639089828 531645596 916058187 600630503 840782051 708383471 49117950 73706617 395892910 661118694 514834322 747507474 784583688 8120420 785172564 202225815 395461385 329955280 707332907 384198584 526825979 317466872 23485196 756889488 127357191 999279490 117735511 494254773 230445938 235207288 245425066 421294102 462512567 549660387 455318568 146522041 430988712 615617285 611383727 577370320 540734620 495948100 670658950 892891455 860894688 563317729 429546873 778959270 350826424 271087501 769203472 423812394 499657805 483259652 919014900 340112465 862270376 927222902 825008827 6535…
Output: -465276585

Example 2:

Input: 342 636885178 274372078 873325734 238573935 655081833 895266280 76093288 174774299 188553214 303335518 83644066 499437447 314494500 547663378 322695581 825077296 354683254 976041020 648097635 108778329 430483887 117743468 208261423 827352579 99595526 888464057 916567482 430021254 60590223 604731179 713122719 226071276 491070308 425421202 864247190 757020301 60615148 67487908 622356259 122184365 183360280 713781692 9798119 866972059 324677500 310263625 588425809 405526829 312452668 489441892 886135604 485386624 196167548 533013318 713289933 49661765 829368883 223424473 950775979 693146790 78728609 28378710 196096775 423385204 451560961 848566551 990238480 954631994 530801516 281306743 683092956 306417660 390069376 767799742 479548866 743571163 209697676 817059111 471939526 829081622 8461979…
Output: -1425753949

Example 3:

Input: 454 39821341 235408177 878627949 156609157 807304599 861105122 359487651 393142933 801183221 958510599 185241859 619366159 292409827 876040659 391231558 598734020 516348367 39838168 656945273 509039557 77795405 287510168 30040578 911823459 947321177 379780769 804757123 14684281 608920728 503810751 873207058 721360579 302392846 73065448 104879516 789332663 756870425 127473966 53994877 254242728 492638286 126228499 507145724 277019788 43312197 488761007 646676478 379134144 338589974 946055876 945678627 679272933 385399751 681955820 507022615 262888127 577368508 491775126 485039250 82006658 518929754 243866162 841973213 195379460 18153486 306526641 132370052 522459179 585703752 842416364 734123639 675382086 534635239 87171805 631498219 142539948 702811247 34684534 304750663 395135250 55556470…
Output: 6912499711

Constraints:

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

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