제출 #3570

#제출 시각아이디문제언어결과실행 시간메모리
3570BothEarRimKing of penalty (kriii1_K)C++98
0 / 1
24 ms1868 KiB
#include <stdio.h>
#include <algorithm>
using namespace std;

long long num[100000]={0};
int main()
{
	long long p,i,j,n;
	long long sum=0,res=0,temp;
	
	scanf("%lld %lld",&p,&n);
	for(i=0 ; i<n ; i++){
		scanf("%lld",&num[i]);
	}i=0;
	sort(num,num+n);
	while(sum + num[i] <= p-1){
		sum += num[i++];
	}
	printf("%d ",i);

	temp = p-1-sum;
	while(i--){
		res += temp + num[i];
		temp += num[i];
	}
	printf("%lld\n",res);
}
#Verdict Execution timeMemoryGrader output
Fetching results...