#include <cstdio> #include <climits> using namespace std; int main() { int notesNumber; int notesValueSum = 0; int currentNoteValue = 0; int smallestOddNoteValue = INT_MAX; scanf("%d", ¬esNumber); for(int i=0; i<notesNumber; i++) { scanf("%d", ¤tNoteValue); notesValueSum = notesValueSum + currentNoteValue; if((currentNoteValue % 2 == 1) && (currentNoteValue < smallestOddNoteValue)) { smallestOddNoteValue = currentNoteValue; } } if((notesNumber == 1) && (notesValueSum % 2 == 1) ) { printf("NIESTETY\n"); } else if(notesValueSum % 2 == 0){ printf("%d\n", notesValueSum); } else { printf("%d\n", notesValueSum-smallestOddNoteValue); } return 0; }
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 | #include <cstdio> #include <climits> using namespace std; int main() { int notesNumber; int notesValueSum = 0; int currentNoteValue = 0; int smallestOddNoteValue = INT_MAX; scanf("%d", ¬esNumber); for(int i=0; i<notesNumber; i++) { scanf("%d", ¤tNoteValue); notesValueSum = notesValueSum + currentNoteValue; if((currentNoteValue % 2 == 1) && (currentNoteValue < smallestOddNoteValue)) { smallestOddNoteValue = currentNoteValue; } } if((notesNumber == 1) && (notesValueSum % 2 == 1) ) { printf("NIESTETY\n"); } else if(notesValueSum % 2 == 0){ printf("%d\n", notesValueSum); } else { printf("%d\n", notesValueSum-smallestOddNoteValue); } return 0; } |