aboutsummaryrefslogtreecommitdiff
path: root/c/las12uvas/2019/544_queNoSeAtraganten.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c/las12uvas/2019/544_queNoSeAtraganten.cpp')
-rw-r--r--c/las12uvas/2019/544_queNoSeAtraganten.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/c/las12uvas/2019/544_queNoSeAtraganten.cpp b/c/las12uvas/2019/544_queNoSeAtraganten.cpp
new file mode 100644
index 0000000..d5fe0db
--- /dev/null
+++ b/c/las12uvas/2019/544_queNoSeAtraganten.cpp
@@ -0,0 +1,28 @@
+#include <iostream>
+#include <algorithm>
+
+int main() {
+ int uvas, pesoMax;
+ int previo;
+ int total;
+ while (std::cin >> uvas) {
+ std::cin >> pesoMax;
+ int pesos[uvas];
+ for (int i = 0; i < uvas; i++) {
+ std::cin >> pesos[i];
+ }
+ std::sort(pesos, pesos+uvas);
+ previo = 0;
+ total = 0;
+ for (int i = 0; i < uvas; i++) {
+ if (pesos[i] + previo > pesoMax) {
+ break;
+ }
+ total++;
+ previo = pesos[i];
+ }
+ std::cout << total << std::endl;
+ }
+
+ return 0;
+}