fork download
  1. #include <iostream>
  2.  
  3. using std::cin;
  4. using std::cout;
  5.  
  6. int main() {
  7. int size;
  8. cin >> size;
  9. const int INFINITY = 1001;
  10. int M = INFINITY;
  11. int min = INFINITY;
  12. int min_even = INFINITY;
  13. int next[5];
  14. cin >> next[0] >> next[1] >> next[2] >> next[3] >> next[4];
  15. for (int i = 5; i < size; i++) {
  16. int num;
  17. cin >> num;
  18. int mult = num * min;
  19. if (mult % 2 == 1) {
  20. mult = num * min_even;
  21. }
  22. if (mult < M) {
  23. M = mult;
  24. }
  25. if (next[0] < min) {
  26. min = next[0];
  27. }
  28. if (next[0] % 2 == 0 && next[0] < min_even) {
  29. min_even = next[0];
  30. }
  31. for (int j = 0; j < 4; j++) {
  32. next[j] = next[j + 1];
  33. }
  34. next[4] = num;
  35. }
  36. if (M == INFINITY) {
  37. M = -1;
  38. }
  39. cout << M;
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0s 15224KB
stdin
11
12
45
5
3
17
23
21
20
19
18
17
stdout
54