#include<stdio.h>
#include<algorithm>
using std::sort;
int data[100011];
int main(void)
{
int a, i, sum, n, t = 0, result;
scanf("%d %d",&a,&n);
for(i = 0; i < n; i++)
scanf("%d",&data[i]);
sort( data, data+n );
sum = 0;
for(i = 0; i < n; i++)
{
sum += data[i];
if( sum >= a ) break;
}
result = i;
sum = t = 0;
for(i = result-1; i >= 0; i--)
{
sum += data[i];
t += sum;
}
printf("%d %d",result,t+a);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1476 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |