# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3834 | GhostCode | King of penalty (kriii1_K) | C++98 | 64 ms | 2444 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 <vector>
#include <algorithm>
using namespace std;
int main(void){
unsigned int c_time;
unsigned int p_num;
unsigned int pbm;
unsigned int answer;
vector<unsigned int> problem;
cin>>c_time;
cin>>p_num;
for(int i=0;i<p_num;i++){
cin>>pbm;
problem.push_back(pbm);
}
sort(problem.begin(),problem.end());
unsigned int i=0,sum=0;
while(1){
sum += problem[i];
if(sum >= c_time){
break;
}
i++;
if(problem.size()<=i) break;
}
c_time -= 1;
answer = i;
if(i != 0){
sum = c_time;
}else{
sum = 0;
}
for(int j=0; j < i-1;j++){
c_time = c_time - problem[j];
sum = c_time + sum;
}
cout<< answer <<" " << sum;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |