Created
January 6, 2014 15:01
-
-
Save danicat/8284005 to your computer and use it in GitHub Desktop.
TopCoder SRM 502 Division 2 250 pts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
class TheProgrammingContestDivTwo { | |
public: | |
vector<int> find(int T, vector<int> requiredTime) { | |
vector<int> res; | |
int solved = 0; | |
int penalty = 0; | |
int remaining = T; | |
int elapsed = 0; | |
sort(requiredTime.begin(), requiredTime.end()); | |
for(auto p : requiredTime) { | |
if( p <= remaining ) { | |
remaining -= p; | |
solved++; | |
penalty += elapsed += p; | |
} | |
} | |
res.push_back(solved); | |
res.push_back(penalty); | |
return res; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment