Submission #3467

#TimeUsernameProblemLanguageResultExecution timeMemory
3467wurikijiKing of penalty (kriii1_K)C++98
1 / 1
24 ms2444 KiB
#include <cstdio> #include <cstring> #include <cstdlib> #include <string> #include <vector> #include <sstream> #include <iostream> #include <algorithm> using namespace std; vector<int> ls; int main(void){ int n,p; scanf("%d %d",&p,&n); ls.clear(); for(int i = 0 ; i< n;i++) { int a; scanf("%d",&a); ls.push_back(a); } sort(ls.begin(),ls.end()); int cnt= 0; long long sum = 0; p--; for(int i = 0 ;i < ls.size();i++) { if( p - ls[i] >= 0 ) { sum += p; p -= ls[i]; cnt++; } } printf("%d %lld\n",cnt, sum); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...