Submission #3574

#TimeUsernameProblemLanguageResultExecution timeMemory
3574waps12bKing of penalty (kriii1_K)C++98
1 / 1
24 ms1868 KiB
#include<cstdio> #include<algorithm> using namespace std; #define ll long long ll val[100000]; int main() { ll P, N; scanf("%lld%lld", &P, &N); for(int i = 0 ; i < N ; i++) scanf("%lld", &val[i]); sort(val, val+N); ll cur = P-1, ans = 0, ans_n = 0; for(int i = 0 ; i < N ; i++) { if( cur >= val[i] ) { ans_n++; ans += cur; cur -= val[i]; } else break; } printf("%lld %lld\n", ans_n, ans); }
#Verdict Execution timeMemoryGrader output
Fetching results...