SRM477 DIV2 ImportantTasks

並べ替えて比較するだけ。

#include <iostream>
#include <vector>
#include <string>
#include <functional>
#include <algorithm>

using namespace std;

class ImportantTasks{
public:
	int maximalCost(vector<int> complexity, vector<int> computers)
	{
		int sum = 0;
		int size = computers.size();

		sort(complexity.begin(), complexity.end(), greater<int>());
		sort(computers.begin(), computers.end(), greater<int>());

		for (int i = 0; i < size; i++){
			vector<int>::iterator it;
			for (it = complexity.begin(); it != complexity.end(); it++){
				if (computers[i] >= *it){
					complexity.erase(it);
					sum ++;
					break;
				}
			}
		}
		return sum;
	}
};