CT22170

The Runner-Up Beneath Obsidian Shore

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

It is audit day at the basalt cliffs of Obsidian Shore. Tanya spreads the stamps records across the table and picks up a sharp pencil. 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 <= 374; 0 <= a[i] <= 1000; answers fit a signed 64-bit integer.

Example 1:

Input: 3 135 137 430
Output: 137

Example 2:

Input: 358 89 710 817 442 287 390 323 443 44 138 723 429 715 9 749 226 614 163 348 434 239 176 130 323 74 853 57 836 359 3 207 98 807 22 913 898 286 768 518 153 194 951 641 158 865 221 216 852 735 780 208 11 32 987 586 766 330 969 319 846 883 615 440 873 840 464 18 524 334 756 547 919 217 355 920 976 29 135 726 262 282 923 989 956 893 723 414 348 206 228 453 506 990 327 739 866 309 107 615 653 414 76 421 929 444 867 316 842 386 885 25 68 452 554 99 515 474 859 43 751 125 990 641 255 514 759 276 418 92 628 181 352 963 519 626 509 542 34 285 799 227 901 419 645 502 528 66 106 387 437 72 900 752 321 369 187 827 609 232 167 22 616 663 132 103 801 737 632 612 129 748 53 257 526 765 164 545 326 345 10 765 475 160 175 740 609 247 714 519 295 726 66 632 58 149 940 495 974 972 67 681 830 466 810 3 457 194…
Output: 991

Example 3:

Input: 123 598 561 171 832 893 556 830 928 58 917 913 22 39 134 257 172 749 136 342 160 769 477 530 446 258 262 301 470 971 281 339 171 449 667 576 526 813 293 297 682 309 757 810 238 858 139 636 312 48 878 542 798 142 899 359 555 896 58 78 163 845 195 211 804 221 853 551 798 92 639 19 627 683 931 899 422 623 178 379 223 521 843 909 466 472 412 612 91 630 606 483 751 833 985 136 837 779 777 722 716 479 447 842 822 179 593 517 698 732 496 80 632 481 819 680 607 138 342 303 583 833 458 745
Output: 971

Constraints:

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

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