Last active
October 8, 2019 18:47
-
-
Save samyravitoria/5a296dbb07b90090aad77c5ea6012767 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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