CSES - E4590 2020 0 - Results
Submission details
Task:3-sum
Sender:Javier Gutierrez Ramirez
Submission time:2020-09-11 09:15:32 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:14:26: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (size_t i = 0; i < n; i++)
                        ~~^~~
input/code.cpp:21:15: error: no match for 'operator<<' (operand types are 'std::ostream {aka std::basic_ostream<char>}' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >')
     std::cout <<myvector.end()-2 << ' ' << myvector.end()-1 << ' ' << myvector.end();
     ~~~~~~~~~~^~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/7/iostream:39:0,
                 from input/code.cpp:1:
/usr/include/c++/7/ostream:108:7: note: candidate: std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::basic_ostream<_CharT, _Traits>::__ostream_type& (*)(std::basic_ostream<_CharT, _Traits>::__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; std::basic_ostream<_CharT, _Traits>::__ostream_type = std::basic_ost...

Code

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

int main()
{   
    int n, myint;
    std::vector<int> myvector;

    std::cin >> n;
    for (size_t i = 0; i < n; i++)
    {
        std::cin >> myint;
        myvector.push_back(myint);
    }

    std::nth_element (myvector.begin(), myvector.end()-2, myvector.end());
    std::cout <<myvector.end()-2 << ' ' << myvector.end()-1 << ' ' << myvector.end();

    return 0;
}