Submission #3412

#TimeUsernameProblemLanguageResultExecution timeMemory
3412movie_joKing of penalty (kriii1_K)C++98
1 / 1
24 ms1476 KiB
#include <stdio.h> #include <algorithm> using namespace std; int x[100000]; int main(void) { int P, N, i, t; long long S = 0; scanf("%d %d", &P, &N); for(i = 0; i < N; i++) scanf("%d", x + i); sort(x, x + N); t = P - 1; for(i = 0; i < N && t >= 0; i++) { if(t - x[i] >= 0) S += t; else break; t -= x[i]; } printf("%d %lld\n", i, S); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...