Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
718 B
1
Indexable
Never
#include <iostream>
#include <vector>
#include <algorithm>


int main()
{
	int health = 0;
	int n = 0;
	int m = 0;
	int tmp = 0;
	int damage = 0;
	int count = 0;

	std::cin >> health >> n >> m;
	std::vector<int> g;

	for (int i = 0; i < n; i++) {
		std::cin >> tmp;
		g.push_back(tmp);
	}

	std::sort(g.rbegin(), g.rend());
	
	for (int i = 0; count < m - 1 && i < n; i++) {
		tmp = g[i];
		if ((tmp % 2 == 0)) {
			damage += tmp;
			count++;
		}
	}

	for (int i = 0; i < n; i++) {
		tmp = g[i];
		if ((tmp % 2 == 1)) {
			damage += tmp;
			break;
		}
	}

	std::cout << damage;
	if (damage > health) {
		std::cout << "\nVICTORY";
	}
	else {
		std::cout << "\nDEFEAT";
	}
}
Leave a Comment