Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 49725 Accepted Submission(s):
19456
怎么办呢?多搞几套系统呗!你说说倒蛮容易,成本呢?成本是个大问题啊.所以俺就到这里来求救了,请帮助计算一下最少需要多少套拦截系统.
#include <iostream> #include <cstring> #include <algorithm> #include <cstdio> using namespace std; int main() { int n; int dp[1111], i, j, a[1111]; //dp【i】存储以i为结尾的最长递增子序列个数 while (cin >> n) { int out = 0; for (i = 0; i < n; ++i) { cin >> a[i]; dp[i] = 1; } for (i = 0; i < n; ++i)//最长递增子序列 { for (j = i - 1; j >= 0; j--)//遍历i之前的每一个 { if (a[i] > a[j] )//满足当前的a[i]比j序列末尾的a[j]要大 dp[i] = max(dp[i], dp[j] + 1); } out = out > dp[i] ? out : dp[i]; } printf("%d\n", out); } return 0; }