#include
int main() {
int w, n;
while (scanf("%d%d", &w, &n) != EOF) {
int i, j, money[30002], temp, count = 0;
for (i = 0 ; i < n ; i++)
scanf("%d", &money[i]);
for (i = 1 ; i < n ; i++)
for (j = 0 ; j < i ; j++)
if (money[i] < money[j])
temp = money[i], money[i] = money[j], money[j] = temp;
i = 0, j = n - 1;
while (n > 0) {
if (i == j)
n--, count++;
else if (money[i] + money[j] <= w)
n = n - 2, i++, j--, count++;
else
n--, j--, count++;
}
printf("%d\n", count);
}
return 0;
}
#include
#include
#include
using namespace std;
struct node
{
int flag;
int num;
}a[30010];
int cmp(node x,node y)
{
if(x.num!=y.num) return x.num>y.num;
}
int main()
{
int i,j,n,m,sum,x;
scanf("%d%d",&n,&m);
memset(a,0,sizeof(a));
for(i=0;iscanf("%d",&a[i].num);
sort(a,a+m,cmp);
sum=0;
for(i=0;i{
x=0;
for(j=m-1;j>=0;j--)
{
if(j==i)
continue;
if(a[i].num+a[j].num<=n&&a[j].flag==0&&a[i].flag==0)
{
a[j].flag=1;
a[i].flag=1;
sum++;
x=1;
break;
}
}
if(x==0&&a[i].flag==0){ sum++;}
}
printf("%d\n",sum);
return 0;
}