CT24029

Innkeeper Counts the lanterns

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Innkeeper found an old ledger of lanterns in the dairy attic at the floating docks of Skyharbor. The margin notes pose a precise question. 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 <= 338; -100 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 238 725 275 860 915 940 53 667 875 230 -58 163 -37 278 11 511 119 40 28 202 283 62 307 216 349 475 92 287 -23 853 295 982 750 278 589 814 176 505 477 567 618 197 345 984 -41 7 492 621 768 433 241 231 71 370 95 816 973 645 87 930 823 680 -31 871 3 818 754 840 583 701 69 124 597 -2 271 638 961 510 883 114 -18 219 812 186 619 152 -96 749 615 110 279 664 -82 -51 638 947 5 703 474 444 812 79 992 353 897 854 932 309 190 765 -57 251 863 370 292 320 783 8 804 32 519 202 558 196 118 -54 77 295 725 961 22 413 639 43 6 993 662 835 25 642 817 569 995 329 -47 805 203 224 793 229 641 557 465 -82 683 -36 88 193 -72 807 658 453 22 76 643 313 952 738 754 488 929 91 275 830 911 38 570 333 355 975 197 908 908 843 864 125 746 508 236 88 411 316 737 170 904 548 842 818 950 562 677 223 6 337 -75 449 282 863 827 421 697 777 123 544 562 764 861 851 793 788 413 842 260 865 434 652 333 381 400 832 393 231 473 560 -14 -70 601 119 884
Output: 1915

Example 2:

Input: 231 523 281 955 498 881 158 833 324 900 871 139 379 310 98 135 344 207 750 131 473 -74 40 947 613 724 657 21 125 917 417 195 365 327 313 286 394 516 303 855 100 433 567 625 974 695 627 635 -82 621 231 565 441 827 759 204 360 7 724 -96 606 416 855 147 402 801 621 41 502 371 785 -67 405 -75 900 64 231 634 463 601 217 719 232 688 4 332 342 510 550 625 126 389 740 367 150 925 359 403 -99 437 350 36 919 969 192 -81 441 203 984 481 425 624 401 822 149 847 655 965 837 -61 409 705 -97 236 304 755 445 719 531 23 986 950 600 254 976 181 919 787 756 561 682 941 158 738 165 365 0 371 931 75 753 763 137 -42 686 702 -82 504 50 661 320 308 120 284 749 719 780 676 758 297 467 70 567 97 440 730 -17 964 826 779 113 595 827 838 427 400 -82 460 570 660 834 827 129 378 55 821 841 368 967 692 798 704 891 649 128 482 672 988 878 476 440 688 963 467 574 728 669 995 638 -72 978 221 -62 287 459 111 488 328 150 453 776 447
Output: 2253

Example 3:

Input: 263 376 564 198 817 219 233 737 -65 810 912 106 -11 667 343 93 534 508 63 762 170 948 731 124 872 546 472 115 793 536 945 -100 689 234 -53 -66 -38 516 997 329 95 366 530 978 303 -15 970 25 625 12 366 531 230 341 881 583 -75 90 702 854 -77 762 319 977 111 257 586 -27 388 -7 289 519 860 951 191 349 555 904 -73 736 624 609 615 388 641 -51 342 741 160 -18 305 79 865 477 963 946 539 412 -93 569 808 88 766 439 668 9 467 519 515 352 -79 462 17 106 533 169 642 344 115 -92 251 533 -41 852 501 834 815 139 913 925 777 54 334 92 802 324 968 364 -87 950 -7 79 327 -34 390 0 319 150 855 478 399 -36 965 421 460 526 412 861 503 142 -72 71 698 860 440 894 865 17 407 -33 811 732 929 943 327 588 680 133 331 891 239 880 81 351 284 739 634 605 318 67 437 126 614 774 665 766 744 626 912 799 862 433 -17 507 959 332 -30 967 671 201 984 342 -42 364 -13 407 110 498 242 132 608 922 105 677 522 332 756 785 675 520 546 765 29 468 -5 479 112 526 54 748 121 319 904 572 943 958 419 548 959 436 621 35 504 115 474 -55 690 115 601 485 689 560 72 293
Output: -3821

Constraints:

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

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