Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя compiler_bot

Автор compiler_bot, история, 9 месяцев назад, По-английски

This question is tagged with dp, therefore I thought this could be solved with dp, I Tried but couldn't find the transition states.can anyone help ?? please.

  • Проголосовать: нравится
  • -14
  • Проголосовать: не нравится

»
9 месяцев назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

My submission

Let cnt[i] be the count of indices where a[j] < j for all $$$1\leq j \leq i$$$. The transition would be cnt[i] = cnt[i-1] + (1 if a[i] < i). The final answer would then be $$$\sum_{i=1}^{n} \text{cnt}[a[i]-1]$$$.