TOPIC
Wrong answer 50%
Marcelo asked 3 years ago
Já tentei vários casos, nenhum passa errado.
#define MAXN 100100
using namespace std;
int N, V[MAXN], Atl;
long long int Max_dis;
long long int my_max(long long int n1, long long int n2) {
if (n1 < n2)
return n2;
return n1;
}
void max_ret(int inic, int id) {
Atl = id + 1;
if (Atl == N) {
Max_dis = my_max(Max_dis, ((Atl - inic) * V[id]));
return;
}
if (V[id] == 0) { max_ret(Atl, Atl); return; }
while (V[id] <= V[Atl] && Atl != N) {
if (V[id] == V[Atl]) max_ret(inic, Atl);
if (V[id] < V[Atl]) max_ret(id + 1, Atl);
}
Max_dis = my_max(Max_dis, (Atl - inic) * V[id]);
}
int main() {//2 1 4 0 1 3 3
while(scanf("%d", &N) && N != 0) {
for (int i = 0; i < N; i++)
scanf("%d", &V[i]);
Atl = 0; Max_dis = 0;
while (Atl != N)
max_ret(0, Atl);
printf("%lld\n", Max_dis);
}
return 0;
}
No pior caso, pelo que pude ver, o tamanho do retângulo será 100000(número de retângulos máximos de um caso de teste) x 1000000000(Tamanho máximo de um retângulo) = 10^14, que cabe em um inteiro long long, correto?
This topic has not been answered yet. Be the first!