Submission #4066

#TimeUsernameProblemLanguageResultExecution timeMemory
4066shinhj88King of penalty (kriii1_K)C++98
0 / 1
24 ms1624 KiB
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int P,N; vector<int> data; void input() { scanf("%d%d",&P,&N); data.resize(N); for(int i=0;i<N;i++) { scanf("%d",&data[i]); } sort(data.begin(),data.end()); } void process() { P--; long long int ans=0,sum=0; int i; for(i=0;i<N;i++) { if(P-data[i]<0)break; P-=data[i]; ans=ans+data[i]*(i+1); } printf("%d %lld\n",i,P*i+ans); } int main() { input(); process(); }
#Verdict Execution timeMemoryGrader output
Fetching results...