Language: C++

#include<bits/stdc++.h>
using namespace std;

bitset<2000009> dp;

int main()
{
    int n, i, j, a[2009], sum = 0;

    scanf("%d", &n);
    for(i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
        sum += a[i];
    }

    dp[0] = 1;


    for(i = 0; i < n; i++)
    {
        for(j = sum/2; j >= a[i]; j--)
        {
            dp[j] |= dp[j - a[i]];
        }
    }

    for(i = sum/2; i >= 0; i--)
    {
        if(dp[i])
        {
            printf("%d", sum - i);
            return 0;
        }
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:24:19: error: no match for 'operator|=' (operand types are 'std::bitset<2000009>::reference' and 'std::bitset<2000009>::reference')
   24 |             dp[j] |= dp[j - a[i]];
      |             ~~~~~~^~~~~~~~~~~~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:41,
                 from a.cc:1:
/usr/include/c++/14/cstddef:168:3: note: candidate: 'constexpr std::byte& std::operator|=(byte&, byte)'
  168 |   operator|=(byte& __l, byte __r) noexcept
      |   ^~~~~~~~
/usr/include/c++/14/cstddef:168:20: note:   no known conversion for argument 1 from 'std::bitset<2000009>::reference' to 'std::byte&'
  168 |   operator|=(byte& __l, byte __r) noexcept
      |              ~~~~~~^~~
In file included from /usr/include/c++/14/streambuf:43,
                 from /usr/include/c++/14/bits/streambuf_iterator.h:35,
                 from /usr/include/c++/14/iterator:66,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:54:
/usr/include/c++/14/bits/ios_base.h:104:3: note: candidate: 'constexpr const std::_Ios_Fmtflags& std::operator|=(_Ios_Fmtflags&, _Ios_Fmtflags)'
  104 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:104:29: note:   no known conversion for argument 1 from 'std::bitset<2000009>::reference' to 'std::_Ios_Fmtflags&'
  104 |   operator|=(_Ios_Fmtflags& __a, _Ios_Fmtflags __b) _GLIBCXX_NOTHROW
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:154:3: note: candidate: 'constexpr const std::_Ios_Openmode& std::operator|=(_Ios_Openmode&, _Ios_Openmode)'
  154 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:154:29: note:   no known conversion for argument 1 from 'std::bitset<2000009>::reference' to 'std::_Ios_Openmode&'
  154 |   operator|=(_Ios_Openmode& __a, _Ios_Openmode __b) _GLIBCXX_NOTHROW
      |              ~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/ios_base.h:201:3: note: candidate: 'constexpr const std::_Ios_Iostate& std::operator|=(_Ios_Iostate&, _Ios_Iostate)'
  201 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
      |   ^~~~~~~~
/usr/include/c++/14/bits/ios_base.h:201:28: note:   no known conversion for argument 1 from 'std::bitset<2000009>::reference' to 'std::_Ios_Iostate&'
  201 |   operator|=(_Ios_Iostate& __a, _Ios_Iostate __b) _GLIBCXX_NOTHROW
      |              ~~~~~~~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:176:
/usr/include/c++/14/future:185:18: note: candidate: 'constexpr std::launch& std::operator|=(launch&, launch)'
  185 |   inline launch& operator|=(launch& __x, launch __y) noexcept
      |                  ^~~~~~~~
/usr/include/c++/14/future:185:37: note:   no known conversion for argument 1 from 'std::bitset<2000009>::reference' to 'std::launch&'
  185 |   inline launch& operator|=(launch& __x, launch __y) noexcept
      |                             ~~~~~~~~^~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:198:
/usr/include/c++/14/charconv:646:3: note: candidate: 'constexpr std::chars_format& std::operator|=(chars_format&, chars_format)'
  646 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |   ^~~~~~~~
/usr/include/c++/14/charconv:646:28: note:   no known conversion for argument 1 from 'std::bitset<2000009>::reference' to 'std::chars_format&'
  646 |   operator|=(chars_format& __lhs, chars_format __rhs) noexcept
      |              ~~~~~~~~~~~~~~^~~~~