Submission #3981

#TimeUsernameProblemLanguageResultExecution timeMemory
3981zzapcoderKing of penalty (kriii1_K)C++98
1 / 1
68 ms2060 KiB
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int n,p; cin>>p>>n; vector<int> vll(n,0); for(int i=0;i<n;++i) cin>>vll[i]; sort(vll.begin(), vll.end()); int leftTime = p-1; long long ans = 0, idx = 0; while( leftTime >= 0 ){ if(idx < vll.size() && vll[idx] <= leftTime){ ans += leftTime; leftTime -= vll[idx]; idx++; } else break; } cout<<idx<<' '<<ans<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...