Submission #4050

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