CT25696

The Starlit crates of Porter

EasyL3 · Syntax SurferAcceptance: 0.0%XP: 20

Porter the quartermaster watches over the rook towers of Chessfield's stores of crates. A careful computation stands between order and chaos. 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 <= 436; 0 <= a[i] <= 1000000000; answers fit a signed 64-bit integer.

Example 1:

Input: 33 813514609 228620629 650096031 720327336 112744816 973838723 76147058 125064370 752553347 502202302 366617305 905280654 924605187 364490433 375121403 901305424 301921291 18583036 816165096 380551814 321615169 48121320 257133016 71984361 361124635 373634694 283124582 482582775 680764245 393855321 881598397 166081981 958824282
Output: 958824282

Example 2:

Input: 73 832423126 397091226 293283735 110772091 128929933 19719321 782217687 862139396 808568503 777671233 744438863 190453300 723387508 293660717 27787136 892570841 208640132 489380694 972922941 246316331 469480692 381230291 540412237 667817784 910572221 629662969 771586364 223632635 396516899 462924872 992399548 733212665 795700760 157686727 469714349 558484936 313728679 385739969 664304165 600466350 826272493 650862347 277041901 126984282 568236947 658287426 538061713 442839895 946436464 137683813 83138798 131626190 730320112 848539669 257011381 596825377 767457724 932343288 270711471 349545827 483132201 266504625 795296262 272423854 797308688 466713978 355361443 716390813 199141847 506240042 100796845 879126497 561043010
Output: 972922941

Example 3:

Input: 309 20775806 254759983 343593549 221170240 800383657 254066580 22822644 632210382 960351265 847969883 967652339 774239103 155196605 900209287 758908320 857083859 856601765 799230009 992789901 98532104 792861656 462595926 125870579 186012175 422593965 790932975 252898954 916049127 121022911 625869984 232049735 405749540 852031905 682000176 426924697 950351836 147971031 397361511 996372380 827964350 695409016 779880320 670283 854578128 253450084 768191223 103615869 683216300 685694877 450730867 738768887 312190325 485288150 534270464 331045419 923248437 583699381 859287801 785484229 497058346 340661512 555334217 450897849 639445973 490349217 348877361 377071247 546457300 209656385 697410647 215463333 275511301 277406326 364749862 375938054 436817114 834585751 821580254 851744970 616998630 59…
Output: 996372380

Constraints:

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

Loading...
Test Cases:No test cases
No test cases available.
The Starlit crates of Porter - EASY Coding Problem | CodeTikki