Submission #3388

#TimeUsernameProblemLanguageResultExecution timeMemory
3388Apple_CplusKing of penalty (kriii1_K)C++98
1 / 1
24 ms2064 KiB
#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 timeMemoryGrader output
Fetching results...