B. Once Again...
Time Limit: 1 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/582/problem/BDescription
You are given an array of positive integers a1, a2, ..., an × T of length n × T. We know that for any i > n it is true that ai = ai - n. Find the length of the longest non-decreasing sequence of the given array.
Input
The first line contains two space-separated integers: n, T (1 ≤ n ≤ 100, 1 ≤ T ≤ 107). The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 300).
Output
Print a single number — the length of a sought sequence.
Sample Input
4 3 3 1 4 2
Sample Output
5
HINT
题意
给你一个n*t这么长的序列,然后求最长不递减序列
其中a[i+n]=a[i]
题解:
暴力,如果t<=300,我们就直接暴力求就好了
如果t>的话,我们就大胆猜测,中间肯定是连续选一个数
那么我们就预处理前面以a[i]开始的最长,和后面的以a[i]最长是啥就好了~
代码:
#include#include #include #include