Submission #3477

#TimeUsernameProblemLanguageResultExecution timeMemory
3477blmarketKing of penalty (kriii1_K)C++98
1 / 1
24 ms2060 KiB
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <sstream> #include <numeric> #include <iterator> #include <queue> #include <set> #include <map> #include <vector> #define mp make_pair #define pb push_back #define sqr(x) ((x)*(x)) #define foreach(it,c) for(typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it) using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; typedef vector<string> VS; typedef pair<int,int> PII; template<typename T> int size(const T &a) { return a.size(); } int P,C; vector<int> V; long long solve(int i) { long long ret = 0; int pen = P - 1; for(int j=0;j<i;j++) { ret += pen; pen -= V[j]; } return ret; } int main(void) { scanf("%d %d",&P, &C); V.resize(C); for(int i=0;i<C;i++) { scanf("%d", &V[i]); } sort(V.begin(), V.end()); long long ret = 0; int sum = 0; for(int i=0;i<size(V);i++) { sum += V[i]; if(sum >= P) { cout << i << " " << solve(i) << endl; return 0; } } cout << C << " " << solve(C) << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...