CT26657

The Highreach Even Minus Odd

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Legend says the vault under the mountain city of Highreach opens only for a perfect tally of stamps. Tina means to find out. 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 <= 549; 0 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 247 72457 248951 612731 353342 395730 993546 633146 941745 852542 514377 163270 322140 34312 825724 731370 99683 727597 273909 787700 433066 242440 262237 217979 462446 179007 30769 700684 604287 459754 491424 951595 403407 854465 136107 441104 752736 890248 334761 931798 112028 149971 499291 827812 602978 66336 575665 243871 499501 54010 547439 321943 142966 7471 727464 699301 662095 865728 962273 486971 443584 238251 70490 171193 604647 206283 7594 602603 871276 578525 293591 591282 361211 580635 290902 575080 545825 669197 546298 549521 829692 531354 156518 579415 33137 50681 432458 3529 17246 346696 92853 810023 218982 110728 564864 940539 444396 431358 417987 148668 636472 831262 705772 503166 165248 366163 139391 375112 567232 334828 20994 950210 762421 744841 580208 892896 835559 79…
Output: 3055104

Example 2:

Input: 36 415828 902624 887422 250229 668626 307230 669972 344533 247538 174304 21703 523541 867616 376907 334823 153009 51095 667401 946285 954027 404014 370637 813481 824097 612704 771719 979513 984077 757360 737668 509189 382759 792310 730146 815757 386232
Output: 954096

Example 3:

Input: 387 55566 758865 262289 152782 31197 871882 15993 98622 82647 811527 959948 117120 129797 387362 792094 524659 486431 401920 478401 780642 599193 721969 290219 954449 176304 656841 637096 31255 488563 75755 972200 818393 381963 525381 58402 845242 695470 766037 407325 180875 247111 832744 80800 964710 999108 149894 649707 470110 144437 555177 856520 934068 368038 738505 323234 141557 10774 819481 71641 662463 499123 809446 293068 648294 907667 346715 72746 986271 170836 839305 370931 899371 57231 300998 621309 788193 526676 28147 59351 438415 990614 695064 157867 912049 911115 642150 976348 309557 191013 222058 762125 111310 318186 548739 958688 455161 341816 8073 989929 518361 491982 870744 119647 664165 712305 361108 478508 974012 483440 579573 98549 573996 64945 931956 695712 592891 672…
Output: -10728419

Constraints:

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

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