Submission #3424

#TimeUsernameProblemLanguageResultExecution timeMemory
3424joinsungKing of penalty (kriii1_K)C++98
1 / 1
68 ms3212 KiB
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { long long p, n; cin >> p >> n; vector<long long> time; for (long long ni=0;ni<n;ni++) { long long t; cin >> t; time.push_back(t); } sort(time.begin(), time.end()); long long penalty = 0; long long t = p-1; long long count = 0; for (long long ni=0;ni<n;ni++) { t -= time[ni]; if (t < 0) break; penalty += t + time[ni]; count++; } cout << count << " " << penalty << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...