Submission #3443

#TimeUsernameProblemLanguageResultExecution timeMemory
3443pl0892029King of penalty (kriii1_K)C++98
1 / 1
24 ms1476 KiB
#include <cstdio> #include <algorithm> using namespace std; int Problem[100000]; int main() { int P, N; scanf("%d %d",&P,&N); for(int i=0;i<N;i++) scanf("%d",Problem+i); sort(Problem,Problem+N); int sum = 0, idx = 0; for(int i=0;i<N;i++) { sum += Problem[i]; if(sum >= P) break; idx = i; } printf("%d ",idx+1); // Maximum solving problems for(int i=idx-1;i>=0;i--) Problem[i] += Problem[i+1]; long long panelty = 0; for(int i=idx;i>=0;i--) panelty += Problem[i] + P-Problem[0]-1; printf("%lld",panelty); }
#Verdict Execution timeMemoryGrader output
Fetching results...