Language: C++


        #include <bits/stdc++.h>

        using namespace std;

        int main(){
          int K,N,i,j;
          long long z=0;
          scanf("%d %d",&N,&K);
          long long lista[N];
          for(i=0;i<N;i++){
            scanf("%lld",lista+i);
          }
          sort(lista,lista+N);
          reverse(lista,lista+N)
          if(K>N)
          {
              printf("%d",0);
              return 0;
          }
          for(i=N-K-1;i<N;i++){
                list[i]=0;
          }
          for(i=0;i<N;i++)
          {
              z+=list[i];
          }
          printf("%lld",z);


        return 0;}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:33: error: expected ';' before 'if'
   15 |           reverse(lista,lista+N)
      |                                 ^
      |                                 ;
   16 |           if(K>N)
      |           ~~                     
a.cc:22:25: error: class template argument deduction failed:
   22 |                 list[i]=0;
      |                         ^
a.cc:22:25: error: no matching function for call to 'list(int)'
In file included from /usr/include/c++/14/list:65,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:150,
                 from a.cc:2:
/usr/include/c++/14/bits/stl_list.h:2112:5: note: candidate: 'template<class _InputIterator, class _ValT, class _Allocator, class, class> std::__cxx11::list(_InputIterator, _InputIterator, _Allocator)-> list<_ValT, _Allocator>'
 2112 |     list(_InputIterator, _InputIterator, _Allocator = _Allocator())
      |     ^~~~
/usr/include/c++/14/bits/stl_list.h:2112:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidate: 'template<class _Tp, class _Alloc> list(std::__cxx11::list<_Tp, _Alloc>)-> std::__cxx11::list<_Tp, _Alloc>'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note:   template argument deduction/substitution failed:
a.cc:22:25: note:   mismatched types 'std::__cxx11::list<_Tp, _Alloc>' and 'int'
   22 |                 list[i]=0;
      |                         ^
/usr/include/c++/14/bits/stl_list.h:750:7: note: candidate: 'template<class _Tp, class _Alloc> list()-> std::__cxx11::list<_Tp, _Alloc>'
  750 |       list() = default;
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:750:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/stl_list.h:785:7: note: candidate: 'template<class _Tp, class _Alloc> list(std::size_t, const _Tp&, const _Alloc&)-> std::__cxx11::list<_Tp, _Alloc>'
  785 |       list(size_type __n, const value_type& __value,
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:785:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_list.h:812:7: note: candidate: 'template<class _Tp, class _Alloc> list(const std::__cxx11::list<_Tp, _Alloc>&)-> std::__cxx11::list<_Tp, _Alloc>'
  812 |       list(const list& __x)
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:812:7: note:   template argument deduction/substitution failed:
a.cc:22:25: note:   mismatched types 'const std::__cxx11::list<_Tp, _Alloc>' and 'int'
   22 |                 list[i]=0;
      |                         ^
/usr/include/c++/14/bits/stl_list.h:825:7: note: candidate: 'template<class _Tp, class _Alloc> list(std::__cxx11::list<_Tp, _Alloc>&&)-> std::__cxx11::list<_Tp, _Alloc>'
  825 |       list(list&&) = default;
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:825:7: note:   template argument deduction/substitution failed:
a.cc:22:25: note:   mismatched types 'std::__cxx11::list<_Tp, _Alloc>' and 'int'
   22 |                 list[i]=0;
      |                         ^
/usr/include/c++/14/bits/stl_list.h:835:7: note: candidate: 'template<class _Tp, class _Alloc> list(std::initializer_list<_Tp>, const _Alloc&)-> std::__cxx11::list<_Tp, _Alloc>'
  835 |       list(initializer_list<value_type> __l,
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:835:7: note:   template argument deduction/substitution failed:
a.cc:22:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   22 |                 list[i]=0;
      |                         ^
/usr/include/c++/14/bits/stl_list.h:840:7: note: candidate: 'template<class _Tp, class _Alloc> list(const std::__cxx11::list<_Tp, _Alloc>&, std::__type_identity_t<_Alloc>&)-> std::__cxx11::list<_Tp, _Alloc>'
  840 |       list(const list& __x, const __type_identity_t<allocator_type>& __a)
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:840:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_list.h:845:7: note: candidate: 'template<class _Tp, class _Alloc> list(std::__cxx11::list<_Tp, _Alloc>&&, const _Alloc&, std::true_type)-> std::__cxx11::list<_Tp, _Alloc>'
  845 |       list(list&& __x, const allocator_type& __a, true_type) noexcept
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:845:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_list.h:849:7: note: candidate: 'template<class _Tp, class _Alloc> list(std::__cxx11::list<_Tp, _Alloc>&&, const _Alloc&, std::false_type)-> std::__cxx11::list<_Tp, _Alloc>'
  849 |       list(list&& __x, const allocator_type& __a, false_type)
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:849:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/stl_list.h:860:7: note: candidate: 'template<class _Tp, class _Alloc> list(std::__cxx11::list<_Tp, _Alloc>&&, std::__type_identity_t<_Alloc>&)-> std::__cxx11::list<_Tp, _Alloc>'
  860 |       list(list&& __x, const __type_identity_t<allocator_type>& __a)
      |       ^~~~
/usr/include/c++/14/bits/stl_list.h:860:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_list.h:880:9: note: candidate: 'template<class _Tp, class _Alloc, class _InputIterator, class> list(_InputIterator, _InputIterator, const _Alloc&)-> std::__cxx11::list<_Tp, _Alloc>'
  880 |         list(_InputIterator __first, _InputIterator __last,
      |         ^~~~
/usr/include/c++/14/bits/stl_list.h:880:9: note:   candidate expects 2 arguments, 1 provided
a.cc:22:25: note: explicit deduction guides not considered for copy-initialization
   22 |                 list[i]=0;
      |                         ^
a.cc:26:22: error: missing template arguments before '[' token
   26 |               z+=list[i];
      |                      ^