#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+1);
for(int i=0;i<N;i++)
{
scanf("%d",&data[i]);
}
sort(data.begin(),data.end());
}
void process()
{
P--;
long long int ans=0;
int i;
for(i=0;i<=N;i++)
{
if(P-data[i]<0)break;
ans+=P;
P-=data[i];
}
printf("%d %lld\n",i,ans);
}
int main()
{
input();
process();
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1236 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |