// // main.cpp // Potyczki2015 - KIE // // Created by Kamil Górzyński on 28/09/15. // Copyright © 2015 Kamil Górzyński. All rights reserved. // #include <stdio.h> #include <queue> #include <vector> int n, temp, counter; bool czybylnieparz; std::priority_queue<int, std::vector<int>, std::greater<int> >que; int main(int argc, const char * argv[]){ scanf("%d", &n); for(int i=0; i<n; ++i) { scanf("%d", &temp); que.push(temp); } while (! que.empty() ) { if(!czybylnieparz && que.top()%2==1){ que.pop(); czybylnieparz=1; } else { counter+=que.top(); que.pop(); } } if(counter==0)printf("NIESTETY"); else printf("%d", counter); 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 31 32 33 34 35 36 37 38 | // // main.cpp // Potyczki2015 - KIE // // Created by Kamil Górzyński on 28/09/15. // Copyright © 2015 Kamil Górzyński. All rights reserved. // #include <stdio.h> #include <queue> #include <vector> int n, temp, counter; bool czybylnieparz; std::priority_queue<int, std::vector<int>, std::greater<int> >que; int main(int argc, const char * argv[]){ scanf("%d", &n); for(int i=0; i<n; ++i) { scanf("%d", &temp); que.push(temp); } while (! que.empty() ) { if(!czybylnieparz && que.top()%2==1){ que.pop(); czybylnieparz=1; } else { counter+=que.top(); que.pop(); } } if(counter==0)printf("NIESTETY"); else printf("%d", counter); return 0; } |