#include <iostream>
#include <algorithm>
using namespace std;
int a[100000];
int main()
{
int p,n;
int i;
int tot;
cin>>p>>n;
for(i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
tot=0;
i=0;
p--;
while(p-a[i]>0)
{
tot+=p;
p-=a[i];
i++;
}
cout<<i<<' '<<tot;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
2064 KB |
Output is correct |
2 |
Correct |
0 ms |
2064 KB |
Output is correct |
3 |
Correct |
0 ms |
2064 KB |
Output is correct |
4 |
Correct |
8 ms |
2064 KB |
Output is correct |
5 |
Correct |
0 ms |
2064 KB |
Output is correct |
6 |
Correct |
8 ms |
2064 KB |
Output is correct |
7 |
Correct |
24 ms |
2064 KB |
Output is correct |
8 |
Correct |
28 ms |
2064 KB |
Output is correct |
9 |
Incorrect |
72 ms |
2064 KB |
Output isn't correct |
10 |
Halted |
0 ms |
0 KB |
- |