Increasing Sequence
Time limit3sMemory limit1024 MB
Given a permutation, for each index i, count the indices j other than i whose removal shortens the longest increasing subsequence that contains i.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Binary search, Segment tree
- Solved
- No attempts yet
Problem
You are given a permutation of size . For each , count the indices such that removing decreases the maximum possible length of an increasing subsequence that contains index .
Input
The first line contains an integer .
The next line contains integers .
Output
Print integers, separated by spaces, where the -th integer is the answer for index .
Constraints
- Every is distinct.