Advertisement
Guest User

Untitled

a guest
Mar 19th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int n;
  8. cin>>n;
  9. int mas[n];
  10. int best1=1001;
  11. int best2=1001;
  12.  
  13. queue<int> qq;
  14. for(int i=0; i<5; i++){
  15. cin>>mas[i];
  16. qq.push(mas[i]);
  17. }
  18. for(int i=5; i<n; i++){
  19. cin>>mas[i];
  20. }
  21. int mn=1000*1000+1;
  22. for(int j=0; j <n-5; j++){
  23. for(int i=5+j; i<n; i++){
  24. int te1=best1*mas[i];
  25. int te2=best2*mas[i];
  26. //mn=(mn > te1)&&(!te1%2)? te1:mn;
  27. if(mn>te1&&te1%2==0)mn=te1;
  28. if(mn>te2&&te2%2==0)mn=te2;
  29. //mn=(mn > te2)&&(!te2%2)? te2:mn;
  30.  
  31. }
  32. // best1= (best1 > qq.front())&&(!best1%2)? qq.front():best1 ;
  33. if(best1>qq.front()&&qq.front()%2==1)best1=qq.front();
  34. if(best2>qq.front()&&qq.front()%2==0)best2=qq.front();
  35. // best2= (best2 > qq.front())&&(best2%2)? qq.front():best2 ;
  36. qq.pop();
  37. qq.push(mas[j+5]);
  38. }
  39.  
  40. cout<<(mn%2==0 ? mn:-1);
  41. //cout<<mn ;
  42.  
  43. return 0;
  44. }
  45. /*
  46. 11
  47. 12
  48. 45
  49. 5
  50. 7
  51. 17
  52. 23
  53. 21
  54. 20
  55. 19
  56. 18
  57. 17
  58. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement