Submission #3388

# Submission time Handle Problem Language Result Execution time Memory
3388 2013-08-31T05:16:41 Z Apple_Cplus King of penalty (kriii1_K) C++
1 / 1
24 ms 2064 KB
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <sstream>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
 
using namespace std;
 
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pii pair<int,pi>
#define X first
#define Y second
#define pb push_back
#define ab(x) ((x)<0?(-(x)):(x))
#define xx(x) ((x)*(x))
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>
#define vpi vector<pi>
#define vpll vector<pll>
#define ALL(x) (x).begin(),(x).end()
#define Max (1<<30)
#define LLMax (1ll<<60)
template<class T>string ToString(T t){stringstream s;s<<t;return s.str();}
template<class T>void ToOther(T&t,string a){stringstream s(a);s>>t;}
 
 
int a[100005];
int main(){
	int P,n;cin>>P>>n;
	for(int i=0;i<n;i++)scanf("%d",&a[i]);

	sort(a,a+n);
	P--;
	ll time=0;
	int r=0;
	for(int i=0;i<n;i++){
		if(P<a[i])break;
		else{
			r++;
			time+=(ll)P;
			P-=a[i];
		}
	}
	cout<<r<<" "<<time<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 2064 KB Output is correct
2 Correct 0 ms 2064 KB Output is correct
3 Correct 0 ms 2064 KB Output is correct
4 Correct 4 ms 2064 KB Output is correct
5 Correct 0 ms 2064 KB Output is correct
6 Correct 4 ms 2064 KB Output is correct
7 Correct 4 ms 2064 KB Output is correct
8 Correct 8 ms 2064 KB Output is correct
9 Correct 24 ms 2064 KB Output is correct
10 Correct 20 ms 2064 KB Output is correct
11 Correct 12 ms 2064 KB Output is correct
12 Correct 12 ms 2064 KB Output is correct
13 Correct 0 ms 2064 KB Output is correct
14 Correct 0 ms 2064 KB Output is correct
15 Correct 12 ms 2064 KB Output is correct