Editorial for Хотели


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.
by: maya

Тестовете можете да видите тук.

Примерно решение на C++:

#include<iostream>
#include<string>
using namespace std;
int main()
{
    int n,br1=0,br2=0,max1=0,max2=0;
    cin>>n;
    int h[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>h[i];
    }
    for(int i=1;i<=n;i++)
    {
        if(h[i]>max1)
        {
            br1++;
            max1=h[i]; 
        }
    }
    for(int i=n;i>=1;i--)
    {
        if(h[i]>max2)
        {
            br2++;
            max2=h[i]; 
        }
    }
    cout<<br1<<" "<<br2<<endl; 
    return 0;

Comments

There are no comments at the moment.