CSES - E4590 2019 0 - Results
Submission details
Task:3-sum
Sender:Eero Salla
Submission time:2019-09-06 08:34:08 +0300
Language:C++ (C++11)
Status:COMPILE ERROR

Compiler report

input/code.cpp:5:5: warning: second argument of 'int main(int, int, int, int)' should be 'char **' [-Wmain]
 int main(int a, int b, int n, int t){
     ^~~~
input/code.cpp:5:5: warning: third argument of 'int main(int, int, int, int)' should probably be 'char **' [-Wmain]
input/code.cpp:5:5: warning: 'int main(int, int, int, int)' takes only zero or two arguments [-Wmain]
input/code.cpp: In function 'int main(int, int, int, int)':
input/code.cpp:14:16: error: no match for 'operator-' (operand types are 'std::vector<int>' and 'int')
 cout << num[num-n-i+1] << " ";
             ~~~^~
In file included from /usr/include/c++/7/bits/stl_algobase.h:67:0,
                 from /usr/include/c++/7/bits/char_traits.h:39,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 f...

Code

#include <bits/stdc++.h>
using namespace std;
 
int main(int a, int b, int n, int t){
cin >> n;
vector<int> num;
for(int i = 0; i < n; i++){
cin >> t;
num.push_back(t);
}
sort(num.begin(), num.end());
for(int i = 0; i < 3; i++){
cout << num[num-n-i+1] << " ";
}

}