Submission #3599

#TimeUsernameProblemLanguageResultExecution timeMemory
3599arineKing of penalty (kriii1_K)C++98
1 / 1
24 ms1868 KiB
#include <cstdio> #include <algorithm> using namespace std; typedef long long int lld; lld P, N, data[100005]; int main() { scanf("%lld %lld", &P, &N); for(int i=0; i<N; ++i) scanf("%lld", &data[i]); sort(data, data+N); int T=P-1; lld ans=0, pan=0; for(int i=0; i<N; ++i) { if(T-data[i]<0) break; ++ans; T-=data[i]; pan+=data[i]+T; } printf("%lld %lld", ans, pan); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...