When submitting a solution in C++, please select either C++14 (GCC 6-32) or C++17 (GCC 7-32) as your compiler. ×

Mehak1404's blog

By Mehak1404, history, 4 years ago, In English

155A - I_love_\%username\%

include

using namespace std;

int main() { int n, arr[1001], min=10000, a=0, max=0,b=0; int c=0; cin>>n;

for (int i = 0; i < n; ++i) {
    cin>>arr[i];

    if (max<arr[i]){
        max=arr[i];
        a+=1;
    }    
    if(min>arr[i]){
        min=arr[i];
        b+=1;
    }
}
c=a+b-2;

if(a+b==n && max!=min){
    cout<<(n-1)<<endl;
}
else{
    if(c<0 ){
        cout<<"0"<<endl;
    }
    else{
        cout<<c<<endl;
    }
}
cout<<a<<" "<<b<<endl;

return 0; }

  • Vote: I like it
  • -7
  • Vote: I do not like it

| Write comment?