# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
3615 | shinhj88 | King of penalty (kriii1_K) | C++98 | 200 ms | 1236 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int P,N;
vector<int> data;
long long int now;
long long int ans;
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());
ans=-1;
now=-1;
P--;
}
void process(int choose,long long int sum,long long int p,long long int deep)
{
for(int i=choose;i<N;i++)
{
if(p-data[i]<=0)
{
if(deep>=now)
{
now=deep;
ans=max(ans,p*deep+sum);
}
return;
}
else
{
int t=sum+data[i];
process(i+1,sum+(data[i]*(deep+1)),p-data[i],deep+1);
}
}
}
int main()
{
input();
process(0,0,P,0);
printf("%lld %lld\n",now,ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |