Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main(){
- int n,s=0;
- cin >> n;
- int a[n];
- for (int i=0 ; i< n; i++){
- int q;
- cin >> q;
- a[i]=q;
- if(q>0) s+=q;
- }
- int min = a[0], max = a[0],z1,z2;
- for (int i=1; i< n; i++){
- if (min > a[i]) {
- min = a[i];
- z1 = i;
- }
- if (max < a[i]){
- max = a[i];
- z2 = i;
- }
- }
- if (z2< z1){
- int l=z2; z2=z1; z1=l;
- }
- int pr=1;
- for (int i = z1+1; i < z2; i++)
- pr*=a[i];
- // cout << z1 << ' ' << z2 << ' ' << min << ' ' << max << endl;
- cout << s << ' ' << pr;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement