#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int P,N;
vector<int> data;
void input()
{
scanf("%d%d",&P,&N);
data.resize(N);
for(int i=0;i<N;i++)
{
scanf("%d",&data[i]);
}
sort(data.begin(),data.end());
}
void process()
{
int Sum=0,ans=0;
for(int i=0;i<N;i++)
{
if(Sum+data[i]>=P)
{
ans=(P-1-Sum)+data[i-1];
for(int j=i-2;j>=0;j--)
{
ans+=(ans+data[j]);
}
printf("%d %d",i,ans);
return;
}
Sum+=data[i];
}
}
int main()
{
input();
process();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
1236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |