Skip to content

Instantly share code, notes, and snippets.

@samyravitoria
Last active October 8, 2019 18:47
Show Gist options
  • Save samyravitoria/5a296dbb07b90090aad77c5ea6012767 to your computer and use it in GitHub Desktop.
Save samyravitoria/5a296dbb07b90090aad77c5ea6012767 to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
int n, k, h[1010];
int main()
{
cin >> n >> k;
for(int i = 1 ; i <= n ; ++i) cin >> h[i];
int qtd = 0;
for(int i = 2 ; i < n ; ++i)
{
if(h[i-1] <= h[i] && h[i] >= h[i+1]) // checo se h[i] é um pico, se sim, aumento a quantidade de
{ // picos em 1 unidade
qtd++;
}
}
if(qtd == k) cout << "beautiful\n"; // se existem exatamente k picos
else cout << "ugly\n"; // caso contrário
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment