Main.cc:18:45: error: wrong number of template arguments (0, should be 1) priority_queue , greater <> > pq; ^ In file included from /usr/include/c++/7/string:48:0, from /usr/include/c++/7/bits/locale_classes.h:40, from /usr/include/c++/7/bits/ios_base.h:41, from /usr/include/c++/7/ios:42, 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, from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52, from Main.cc:1: /usr/include/c++/7/bits/stl_function.h:371:12: note: provided for ‘template struct std::greater’ struct greater : public binary_function<_Tp, _Tp, bool> ^~~~~~~ Main.cc:18:47: error: template argument 3 is invalid priority_queue , greater <> > pq; ^ Main.cc: In function ‘int main()’: Main.cc:36:20: error: request for member ‘empty’ in ‘pq’, which is of non-class type ‘int’ while (!pq.empty() && pq.top() < i) ^~~~~ Main.cc:36:34: error: request for member ‘top’ in ‘pq’, which is of non-class type ‘int’ while (!pq.empty() && pq.top() < i) ^~~ Main.cc:37:16: error: request for member ‘pop’ in ‘pq’, which is of non-class type ‘int’ pq.pop(); ^~~ Main.cc:38:16: error: request for member ‘size’ in ‘pq’, which is of non-class type ‘int’ if (pq.size() & 1) ^~~~ Main.cc:42:16: error: request for member ‘push’ in ‘pq’, which is of non-class type ‘int’ pq.push(a[i]); ^~~~ Main.cc:23:10: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d %s", &n, s + 1); ~~~~~^~~~~~~~~~~~~~~~~~~~ Main.cc:27:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &a[i]); ~~~~~^~~~~~~~~~~~~ Main.cc:31:14: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d", &b[i]); ~~~~~^~~~~~~~~~~~~