Submission #3479

#TimeUsernameProblemLanguageResultExecution timeMemory
3479zzapcoderKing of penalty (kriii1_K)C++98
0 / 1
24 ms1976 KiB
#include <stdio.h> #include <vector> #include <algorithm> int P, N; std::vector<int> T; bool compare(int a, int b) { if ( a < b ) return true; else return false; } int main() { scanf("%d %d\n", &P, &N); for ( int i = 0 ; i < N ; i ++) { int tmp; scanf("%d", &tmp); T.push_back(tmp); } sort(T.begin(), T.end()); int i = 0; int sum = 0; P -= 1; while ( T.size() > i && P - T[i] >= 0 ) { sum += P; P -= T[i]; i++; } printf("%d %d",i, sum); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...