#3311. LPERMUT - Longest Permutation
LPERMUT - Longest Permutation
LPERMUT - Longest Permutation
题面翻译
题面:
给你一个序列 含有 个正整数 。 的子集形式类如 ,即必须是连续的。我们感兴趣的是一种子集,它含有元素包括 。( 是子集的大小)。 你的任务是找到这种类型的最长的子集。
输入输出:
Input 第一行,一个数 ,表示序列 的长度 第二行, 个整数,第 个数表示元素 Output 一个数,表示可选子集的长度
说明
你可以选的子集从 开始到 ,这个子集长度为 ,包含了
题目描述
You are given a sequence A of n integer numbers (1<=A <=n). A subsequence of A has the form A , A ... , A (1<=u<=v<=n). We are interested in subsequences that are permutations of 1, 2, .., k (k is the length of the subsequence).
Your task is to find the longest subsequence of this type.
输入格式
- Line 1: n (1<=n<=100000)
- Line 2: n numbers A , A , ... ,A (1<=A <=n)
输出格式
A single integer that is the length of the longest permutation
样例 #1
样例输入 #1
5
4 1 3 1 2
样例输出 #1
3