SRM 502 Div2 Easy

ペナルティーが最小のものから選択するのがベスト

class TheProgrammingContestDivTwo {
public:
  vector <int> find(int T, vector <int> requiredTime) {
    vector <int> res(2);

	sort(requiredTime.begin(), requiredTime.end());
    int n = requiredTime.size();
    int t = 0;
    res[0] = 0;
    res[1] = 0;
    for(int i = 0; i < n; i++){
      if(requiredTime[i] <= T){
        T -= requiredTime[i];
        t += requiredTime[i];
        res[0]++;
        res[1] += t;
      }else{
        break;
      }
    }
    return res;
  }
};