记录编号 |
418594 |
评测结果 |
AAAAAAAAAA |
题目名称 |
嘉豪 |
最终得分 |
100 |
用户昵称 |
HeHe |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.613 s |
提交时间 |
2017-06-30 20:43:19 |
内存使用 |
4.38 MiB |
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int MAXN = 1e6 + 10;
inline char getc(void){
static char buf[1 << 18], *fs, *ft;
return (fs == ft && (ft = (fs = buf) + fread(buf, 1, 1 << 18, stdin)), fs == ft) ? EOF : *fs++;
}
inline int in(void){
register int res = 0;
register char tmp = getc();
while(!isdigit(tmp)) tmp = getc();
while(isdigit(tmp))
res = (res + (res << 2) << 1) + (tmp ^ 48),
tmp = getc();
return res;
}
template<typename T>
void qsort(T *l, T *r);
int N, s[MAXN], cnt;
double V;
int main(){
#ifndef LOCAL
freopen("jiahao1.in", "r", stdin);
freopen("jiahao1.out", "w", stdout);
#endif
V = in(), N = in();
for(int i = 1, *k = s + 1; i <= N; ++i) *(k++) = in();
qsort(s + 1, s + N);
for(int i = 1, *k = s + 1; i <= N; ++i){
if(V <= *k) break;
++cnt;
V += *(k++) * 1.0 / 2;
}
printf("%d\n", cnt);
}
template<typename T>
void qsort(T *l, T *r){
static T tmp;
register T mid = *(l + ((r - l) >> 1));
register T *i = l, *j = r;
do{
while(*i < mid) ++i;
while(mid < *j) --j;
if(i <= j) tmp = *i, *i = *j, *j = tmp, ++i, --j;
}while(i <= j);
if(l < j) qsort(l, j);
if(i < r) qsort(i, r);
return ;
}