[题解]ZOJ Monthly, July 2011beta » ZOJ3519

ZOJ3519
ZOJ3519.cpp


#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int n, iq, jq;
	vector<int> a;

	while (scanf("%d%d", &n, &iq) != EOF) {
		a.resize(n);
		for (int i = 0; i < n; ++i) {
			scanf("%d", &a[i]);
		}
		sort(a.begin(), a.end());
		jq = 0;
		for (int i = 0; i < n; ++i) {
			if (a[i] > iq) {
				iq += 2;
			} else {
				++jq;
			}
		}
		printf("%d\n", iq + jq);
	}

	return 0;
}
Leave a Reply