PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#CC0000066. Nhảy qua những cột trụ (E - Pillars)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Nhảy qua những cột trụ (E - Pillars)
E - Pillars
Source: Codeforces
Version: Phuoc Hung OJ Extended
Problem Statement
There are pillars of heights . A jump may only go from a smaller index to a larger index , and is allowed when . Find a maximum-length sequence of visited pillars and print one optimal sequence of indices.
Input
The first line contains . The second contains heights .
Output
Print the maximum length on the first line and any optimal strictly increasing sequence of 1-based indices on the second line.
Subtasks
Original constraints: ; ; .
- Subtask 1 (20 points): ; ; .
- Subtask 2 (30 points): ; ; .
- Subtask 3 (50 points): ; ; .
Examples
Input
5 2
1 3 6 7 4
Output
4
1 2 3 5
Explanation
Positions have heights , with differences . This is an optimal sequence of length ; other optimal sequences are accepted.