aboutsummaryrefslogtreecommitdiff
path: root/02_sorting_and_searching/missing_coin_sum_2183.cpp
blob: ed7a74b0a855c5474ada21372962f423a80c4e3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
	size_t n, s{1};
	std::cin >> n;
	std::vector<size_t> a(n);
	for (size_t i = 0; i < n; i++)
		std::cin >> a[i];
	std::sort(a.begin(), a.end());
	for (auto c : a)
		if (s < c) break;
		else s+= c;
	std::cout << s << std::endl;
}

Generated with cgit - Back to sebastiano.tronto.net