Last active
November 6, 2019 18:16
-
-
Save sofhiasouza/c5bfb76e9d3613391229e913adcf9c92 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
//Isósceles - 2243 URI | |
//Sofhia de Souza Gonçalves | |
#include <bits/stdc++.h> | |
#define MAXN 50010 | |
using namespace std; | |
int main() | |
{ | |
int n, vet[MAXN]; | |
scanf("%d", &n); | |
for(int i = 1 ; i <= n ; i++) | |
scanf("%d", &vet[i]); //leio os valores das alturas | |
vet[1] = 1; | |
for(int i = 2 ; i <= n ; i++) | |
vet[i] = min(vet[i-1]+1, vet[i]); //atualizo o valor de vet[i] pro maior valor possivel pra ele, respeitando os limites da esquerda | |
vet[n] = 1; | |
int maior = 1; | |
for(int i = n-1 ; i >= 1 ; i--) | |
{ | |
vet[i] = min(vet[i+1]+1, vet[i]); //atualizo o valor de vet[i] pro maior valor possivel pra ele, respeitando os limites da direita | |
maior = max(vet[i], maior); //se vet[i] for maior que o maior atual, atualizo o valor do maior | |
} | |
printf("%d\n", maior); //imprimo o maior | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment