Manurung's blog

By Manurung, 10 years ago, In English

First i want to say sorry because i make a new post for my question, and not make it in the comment of the editorial codeforces round FF.

I need help with 446A. Here's my code: http://codeforces.com/contest/447/submission/7148685

My approach is the following.

- Count the length of the sequence (left & right) for each index i until (n-1), while i start 
  from 0 and n is the number of element.
- i know that the result of the sequence would be like this (something that increasing) + 
  element that can be changed + (something that increasing).
- After that i just count the length of the sequence for each index.

I get WA on the 5th test, it's too big for me to analyse it (I can't even get access to the full example), nor I can get access to the full test data. Would this approach satisfy the time limits, and where is my mistake?

Tags dp
  • Vote: I like it
  • -2
  • Vote: I do not like it

| Write comment?
»
10 years ago, # |
Rev. 4   Vote: I like it +4 Vote: I do not like it

In case Data[a + 1] - Data[a - 1] > 1 change Data[a] to Data[a - 1] + 1, we have new sequence with length kiri[a - 1] + kanan[a + 1] + 1

Otherwise:

  • Change Data[a] to Data[a - 1] + 1, we have length kiri[a - 1] + 1

  • Change Data[a] to Data[a + 1] - 1, we have length kanan[a + 1] + 1

You forgot these 2 cases.

I change your code a bit and got AC: 7149106