fork download
  1. //ssenseeeeeeeeeeeeeeeeeeeeeeeeeeeee
  2. #include<bits/stdc++.h>
  3. #define startt ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  4. typedef unsigned long long ull;
  5. typedef long long ll;
  6. #define MOD 1000000007
  7. #define MX 1000000000
  8. #define MXL 1000000000000000
  9. #define PI 3.14159265
  10. #define pb push_back
  11. using namespace std;
  12. #define sc second
  13. #define endl '\n'
  14. #define fr first
  15.  
  16. int main(){
  17. ll n;
  18. cin >> n;
  19. int a[n+1];
  20. for(int i = 0; i < n; i++)
  21. {
  22. cin >> a[i];
  23. }
  24. int evenpos = -1;
  25. sort(a, a+n);
  26. reverse(a, a+n);
  27. for(int i = 0; i < n; i++)
  28. {
  29. if(a[i]%2 == 0)
  30. {
  31. evenpos = i;
  32. }
  33. }
  34. if(evenpos == -1)
  35. {
  36. cout << -1 << endl;
  37. return 0;
  38. }
  39. for(int i = 0; i < n; i++)
  40. {
  41. if(i == evenpos)
  42. {
  43. continue;
  44. }
  45. cout << a[i];
  46. }
  47. cout << a[evenpos] << endl;
  48. }
  49.  
Success #stdin #stdout 0s 4428KB
stdin
4
8 3 1 5
stdout
5318