Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main()
- {
- int n;
- cin>>n;
- int mas[n];
- int best1=1001;
- int best2=1001;
- queue<int> qq;
- for(int i=0; i<5; i++){
- cin>>mas[i];
- qq.push(mas[i]);
- }
- for(int i=5; i<n; i++){
- cin>>mas[i];
- }
- int mn=1000*1000+1;
- for(int j=0; j <n-5; j++){
- for(int i=5+j; i<n; i++){
- int te1=best1*mas[i];
- int te2=best2*mas[i];
- //mn=(mn > te1)&&(!te1%2)? te1:mn;
- if(mn>te1&&te1%2==0)mn=te1;
- if(mn>te2&&te2%2==0)mn=te2;
- //mn=(mn > te2)&&(!te2%2)? te2:mn;
- }
- // best1= (best1 > qq.front())&&(!best1%2)? qq.front():best1 ;
- if(best1>qq.front()&&qq.front()%2==1)best1=qq.front();
- if(best2>qq.front()&&qq.front()%2==0)best2=qq.front();
- // best2= (best2 > qq.front())&&(best2%2)? qq.front():best2 ;
- qq.pop();
- qq.push(mas[j+5]);
- }
- cout<<(mn%2==0 ? mn:-1);
- //cout<<mn ;
- return 0;
- }
- /*
- 11
- 12
- 45
- 5
- 7
- 17
- 23
- 21
- 20
- 19
- 18
- 17
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement