Submission #3912

# Submission time Handle Problem Language Result Execution time Memory
3912 2013-08-31T09:21:07 Z GhostCode King of penalty (kriii1_K) C++
1 / 1
72 ms 3212 KB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	long long c_time;
	long long p_num;
	long long pbm;
	long long answer;

	vector<long long> problem;

	cin>>c_time;
	cin>>p_num;

	for(int t=0;t<p_num;t++){
		cin>>pbm;
		problem.push_back(pbm);
	}

	sort(problem.begin(),problem.end());

	long long 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
1 Correct 0 ms 1672 KB Output is correct
2 Correct 0 ms 1672 KB Output is correct
3 Correct 0 ms 1672 KB Output is correct
4 Correct 8 ms 2060 KB Output is correct
5 Correct 0 ms 1672 KB Output is correct
6 Correct 8 ms 2060 KB Output is correct
7 Correct 24 ms 2444 KB Output is correct
8 Correct 28 ms 2444 KB Output is correct
9 Correct 72 ms 3212 KB Output is correct
10 Correct 56 ms 3212 KB Output is correct
11 Correct 32 ms 3212 KB Output is correct
12 Correct 24 ms 3212 KB Output is correct
13 Correct 0 ms 1672 KB Output is correct
14 Correct 0 ms 1804 KB Output is correct
15 Correct 20 ms 3212 KB Output is correct