CT1915

Qadir's Solar barrels

EasyL2 · Byte BanditAcceptance: 0.0%XP: 10

Legend says the vault under the gristmill of Rye Hollow opens only for a perfect tally of barrels. Qadir means to find out. Task: Read n integers and print the second distinct largest value. If every value is the same, print -1. Input format: First line: n. Second line: n space-separated integers. Output format: Print the second distinct maximum, or -1 if none. Constraints: 1 <= n <= 70; -1000000 <= a[i] <= 1000000; answers fit a signed 64-bit integer.

Example 1:

Input: 52 700026 958722 -919970 437862 131887 -29772 -449576 763400 66948 -269372 -878647 -198270 891640 48649 445025 -948027 148347 -644069 452210 -856213 511675 -52375 -555153 832373 43091 329192 -105907 -364307 191310 760609 230217 168397 -767015 741061 137303 806823 -575259 251660 -692245 -749704 -678188 -752887 -639948 28988 407250 -73317 131878 -22205 488620 -89058 215130 184167
Output: 891640

Example 2:

Input: 7 -290254 -387752 -761533 -344196 611996 494476 -298362
Output: 494476

Example 3:

Input: 64 98226 200057 -578574 92675 629618 -156258 -73730 -726453 -32761 -155073 320795 948987 158768 321446 430360 24029 621166 -748536 457770 -961224 -33710 -508415 989839 -434139 83952 -982943 -937481 179486 933533 -73169 69263 929844 -110240 449028 -471 -497236 -982341 527311 206928 885174 -308294 -566731 -926100 -133863 113060 369827 623691 31283 288571 301286 -303998 768885 -123875 633968 -713830 851709 257949 -432112 311711 864147 722155 831117 16046 486191
Output: 948987

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
Qadir's Solar barrels - EASY Coding Problem | CodeTikki