CT23711

Alaric's Ledger of stamps

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Every season at the port of Emberfall, someone must recover the missing manifest. This year the task falls to Alaric, armed only with the stamps 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 <= 229; -100 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 36 511 -18 359 948 581 627 450 858 144 256 390 854 -44 988 889 79 269 366 214 564 722 878 529 970 786 444 128 745 -26 210 144 388 384 927 178 732
Output: -4208

Example 2:

Input: 47 852 856 686 -76 917 867 809 366 913 919 -52 420 912 141 434 309 513 631 -45 -99 131 77 884 440 -24 879 962 676 821 246 704 335 919 794 319 230 961 673 381 811 201 419 137 88 171 517 808
Output: 2795

Example 3:

Input: 148 909 777 716 377 610 988 86 617 669 468 686 870 946 459 965 514 269 772 752 990 531 460 558 549 989 954 843 410 -47 115 64 349 914 348 868 626 586 143 850 656 195 -81 289 756 281 226 251 343 555 455 826 182 -89 691 986 293 778 -25 52 344 -23 -55 326 -71 128 731 39 936 536 559 398 965 134 489 366 199 -8 -56 436 834 91 578 364 987 633 820 550 -74 773 199 859 652 699 -88 41 748 -64 -93 97 703 77 -36 519 425 83 2 517 312 350 929 72 675 903 882 -17 793 846 252 943 479 376 545 448 522 -85 876 643 -94 325 -63 544 108 379 960 605 444 30 42 325 264 -5 428 938 865 579 488 751 100
Output: -378

Constraints:

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

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