#include
#include
#include
#include
using namespace std;
int main()
{
int k,n;cin>>k>>n;
vector a(n,0);
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a.begin(),a.end());
vector b(k);
int l=0;
for(int i=n-1;i>n-1-k;i–)
{
b[l]=a[i];
l++;
}
for(int i=n-1-k;i>=0;i–)
{
int m=INT_MAX,pk=0;
for(int j=0;j<k;j++)
{
if(a[i]+b[j]<m)
{
m=a[i]+b[j];
pk=j;
}
}
b[pk]=m;
}
int kp=INT_MIN;
for(int i=0;i<k;i++)
{
if(b[i]>kp)
{
kp=b[i];
}
}
cout<<kp<<endl;
return 0;
}
i think this problem testcases are wrng. can u please check the code and output’s from it with the original output?please