CT23567

The lanterns at Silverfin

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Caravans arrive at the herring shoals of Silverfin with crates of lanterns, and Kian the log keeper must account for every last one. 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 <= 592; -1000000 <= a[i] <= 10; answers fit a signed 64-bit integer.

Example 1:

Input: 449 -929011 -25465 -358389 -542514 -562733 -251664 -139992 -193024 -336247 -581591 -288381 -389518 -143460 -17166 -940092 -701482 -117822 -785541 -608004 -44522 -704560 -56252 -375906 -620831 -220859 -840096 -12233 -298781 -648446 -318493 -646403 -167293 -59157 -234593 -240700 -551613 -758875 -573780 -143997 -189808 -719141 -447373 -423762 -864160 -668083 -983166 -798156 -628553 -505825 -58371 -78368 -629745 -374137 -451154 -803628 -865127 -173984 -589633 -804019 -899675 -715389 -32313 -371703 -362539 -122393 -329762 -425006 -866458 -296024 -620692 -754733 -521321 -283272 -250294 -918941 -647732 -921628 -522157 -565249 -46078 -413983 -530335 -122661 -392466 -742923 -260696 -975748 -94773 -357751 -189929 -674841 -833833 -906777 -707063 -776487 -457993 -95943 -208963 -411556 -927794 -242457 …
Output: 145185

Example 2:

Input: 528 -883844 -237441 -915979 -791309 -644191 -496054 -880010 -26936 -823565 -338504 -308274 -747981 -346080 -314251 -527084 -66880 -418449 -435798 -17394 -536855 -767240 -456140 -224984 -656173 -172886 -796228 -543736 -809730 -751713 -666024 -909663 -415226 -897327 -198907 -689921 -358300 -917700 -555531 -338270 -955456 -476917 -128383 -518533 -35214 -901143 -638590 -622 -715402 -175267 -835523 -413160 -716820 -666325 -272959 -210170 -464805 -489379 -539666 -563562 -464312 -184446 -270005 -107332 -752361 -609883 -256196 -116153 -262035 -847914 -691077 -357265 -834981 -114486 -796821 -575534 -844596 -594931 -803205 -289552 -289162 -379029 -909679 -988708 -532123 -972011 -337168 -696054 -556039 -447675 -853474 -740500 -310723 -246258 -298679 -725092 -791954 -138654 -376564 -947623 -296401 -78…
Output: 9359541

Example 3:

Input: 140 -372071 -565655 -871138 -176867 -915688 -385774 -927504 -945834 -593399 -255037 -388860 -48603 -119575 -410376 -983292 -769443 -405208 -746794 -554080 -191796 -641547 -814964 -638431 -951170 -224218 -174028 -85371 -392700 -145680 -775580 -48917 -420047 -502986 -763715 -436853 -115759 -15996 -6058 -71686 -639242 -440706 -518689 -963883 -835409 -420905 -921126 -477687 -599833 -943773 -595166 -70574 -906956 -595847 -660209 -797069 -550061 -198373 -7289 -533896 -722257 -684239 -468178 -497857 -512084 -391847 -807171 -295598 -329439 -37891 -667756 -203132 -437838 -261469 -241212 -244465 -513073 -396118 -898195 -436798 -372506 -843480 -288687 -614515 -97010 -400923 -956465 -634139 -587468 -795877 -671740 -573226 -691831 -146736 -238784 -204279 -173217 -172968 -816030 -719335 -833513 -879750 …
Output: 4625852

Constraints:

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

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