CSES - E4590 2020 0 - Results
Submission details
Task:3-sum
Sender:Javier Gutierrez Ramirez
Submission time:2020-09-08 11:27:10 +0300
Language:C++ (C++17)
Status:READY
Result:
Test results
testverdicttime
#10.01 sdetails
#20.01 sdetails
#30.01 sdetails
#40.01 sdetails
#50.01 sdetails
#60.01 sdetails
#70.01 sdetails
#80.01 sdetails
#90.01 sdetails
#100.01 sdetails
#110.01 sdetails
#120.01 sdetails
#130.01 sdetails
#140.01 sdetails
#150.01 sdetails
#160.01 sdetails
#170.01 sdetails
#180.01 sdetails
#190.01 sdetails
#200.01 sdetails
#210.01 sdetails
#220.01 sdetails
#230.01 sdetails
#240.01 sdetails
#250.01 sdetails
#260.01 sdetails
#270.01 sdetails
#280.01 sdetails

Code

#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>

int main()
{
    int n;
    int numbers[3];
    std::string token;
    
    if (!(std::cin >> token)) { return -1; }
    std::istringstream(token) >> n;
    // check that the number is bigger than 3?

    if (!(std::cin >> token)) { return -1; }
    std::istringstream(token) >> numbers[0];

    if (!(std::cin >> token)) { return -1; }
    std::istringstream(token) >> numbers[1];

    if (!(std::cin >> token)) { return -1; }
    std::istringstream(token) >> numbers[2];

    std::sort(numbers, numbers + 3);

    for (int i = 0; i != n - 3; i++) {
        int aux;
        std::istringstream(token) >> aux;
        if (aux > numbers[1]) {
            // Then numbers[1] is now the smallest
            numbers[0] = numbers[1];
            if (numbers[2] < aux) {
                numbers[1] = aux;
            } else {
                numbers[1] = numbers[2];
                numbers[2] = aux;
            }
        }
    }

    std::cout << numbers[0] << numbers[1] << numbers[2];

    return 0;
}

Test details

Test 1

Verdict:

input
3
-702 391 288

correct output
-702 391 288

user output
-702288391

Test 2

Verdict:

input
3
-609 886 -448

correct output
-609 886 -448

user output
-609-448886

Test 3

Verdict:

input
3
484 -459 605

correct output
484 -459 605

user output
-459484605

Test 4

Verdict:

input
10
491 934 -395 -873 -822 447 -90...

correct output
491 934 447

user output
-395491934

Test 5

Verdict:

input
10
-293 853 267 -762 -647 843 35 ...

correct output
853 843 744

user output
-293267853

Test 6

Verdict:

input
10
-389 -908 441 187 993 -68 -593...

correct output
441 187 993

user output
-389441441

Test 7

Verdict:

input
4
-195 251 -11 423

correct output
251 -11 423

user output
-195-11251

Test 8

Verdict:

input
4
-522 -222 -909 294

correct output
-522 -222 294

user output
-909-522-222

Test 9

Verdict:

input
4
141 764 -262 3

correct output
141 764 3

user output
-262141764

Test 10

Verdict:

input
5
669 -567 -224 160 194

correct output
669 160 194

user output
-567-224669

Test 11

Verdict:

input
5
294 783 -60 -637 126

correct output
294 783 126

user output
-60294783

Test 12

Verdict:

input
5
-941 391 -339 -982 808

correct output
391 -339 808

user output
-941-339391

Test 13

Verdict:

input
11
726 997 -588 -186 465 472 -865...

correct output
726 997 472

user output
-588726997

Test 14

Verdict:

input
11
-346 950 -522 106 278 265 531 ...

correct output
950 531 678

user output
-522-346950

Test 15

Verdict:

input
11
633 -52 -771 449 409 684 -516 ...

correct output
633 449 684

user output
-771-52633

Test 16

Verdict:

input
57
714 -738 -127 -549 613 11 263 ...

correct output
880 887 947

user output
-738-127714

Test 17

Verdict:

input
57
-599 -338 -960 581 -979 -85 -1...

correct output
830 988 852

user output
-960-599-338

Test 18

Verdict:

input
57
-346 -990 -893 -109 876 438 -5...

correct output
876 910 885

user output
-990-893-346

Test 19

Verdict:

input
99
621 189 655 890 -48 -440 276 6...

correct output
945 962 994

user output
621655655

Test 20

Verdict:

input
99
-617 799 -960 436 725 -177 -30...

correct output
976 930 968

user output
-960-617799

Test 21

Verdict:

input
99
-34 722 -880 -572 -241 415 -28...

correct output
944 893 930

user output
-880-34722

Test 22

Verdict:

input
100
-992 368 517 -516 -307 -813 -3...

correct output
987 983 978

user output
368517517

Test 23

Verdict:

input
100
-410 683 -411 -720 -559 -997 4...

correct output
996 997 1000

user output
-411-410683

Test 24

Verdict:

input
100
42 -652 -295 -94 -213 -974 658...

correct output
960 997 933

user output
-652-29542

Test 25

Verdict:

input
100
230 16 1000 314 599 242 -921 4...

correct output
1000 999 998

user output
23010001000

Test 26

Verdict:

input
100
-557 -203 -490 -20 -187 -727 -...

correct output
-20 -12 -6

user output
-557-490-203

Test 27

Verdict:

input
100
-857 -525 -888 -592 -468 -378 ...

correct output
-1 -16 -34

user output
-888-857-525

Test 28

Verdict:

input
100
-985 -939 -972 -976 -936 -971 ...

correct output
-900 -901 -902

user output
-985-972-939