#include <iostream> using namespace std; int main() { long long int n; long long int a; cin >> n; if (n == 1){ cin >> a; if (a%2 == 1) cout << "NIESTETY"; else cout << a; } else{ long long int odp = 0; long long int ile = 0; long long int najm = 10000; for (long long int i=0; i<n; i++){ cin >> a; odp += a; if (a%2 == 1){ ile++; if (najm > a) najm = a; } } if (ile%2 == 0) cout << odp; else cout << odp - najm; } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <iostream> using namespace std; int main() { long long int n; long long int a; cin >> n; if (n == 1){ cin >> a; if (a%2 == 1) cout << "NIESTETY"; else cout << a; } else{ long long int odp = 0; long long int ile = 0; long long int najm = 10000; for (long long int i=0; i<n; i++){ cin >> a; odp += a; if (a%2 == 1){ ile++; if (najm > a) najm = a; } } if (ile%2 == 0) cout << odp; else cout << odp - najm; } } |