# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
12736 | ainu7 | King of penalty (kriii1_K) | C++98 | 68 ms | 2064 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 <math.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <sstream>
#include <set>
using namespace std;
int main()
{
int P, N;
cin >> P >> N;
long long res = 0;
int cnt = 0;
vector<int> V(N);
for (int i=0; i<N; i++)
cin >> V[i];
sort(V.begin(), V.end());
P --;
for (int i=0; i<N; i++) {
if (P >= V[i]) {
cnt ++;
res += P;
P -= V[i];
}
}
cout << cnt << " " << res << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |