/*
Time:2019.12.1
Author: Goven
type:模拟(数轴)
err:
ref:
*/
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int a[50005];
bool cmp(int x, int y) {
return abs(x) < abs(y);
}
int main()
{
int t, n;
cin >> t >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
sort(a, a + n, cmp);
int pos, sum, i;
pos = sum = i = 0;
while (i < n && sum < t) {
sum += abs(pos - a[i]);
pos = a[i];
i++;
}
i--;
cout << i << endl;
return 0;
}
网友评论