# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3477 | blmarket | King of penalty (kriii1_K) | C++98 | 24 ms | 2060 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |