| Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 163207 | 李鸣 | 导弹拦截问题 | C++ | Accepted | 1 MS | 284 KB | 680 | 2026-10-24 15:55:12 |
#include <iostream> #include <algorithm> using namespace std; const int MAXN = 1005; int a[MAXN]; int dp[MAXN]; // dp[i] 以第i个导弹结尾的最长上升子序列长度 int main() { int n = 0; // 循环读入所有导弹高度,直到输入结束 while (cin >> a[++n]); n--; int ans = 0; for (int i = 1; i <= n; i++) { dp[i] = 1; // 最少自己一个 for (int j = 1; j < i; j++) { if (a[j] < a[i]) // 严格上升 { dp[i] = max(dp[i], dp[j] + 1); } } ans = max(ans, dp[i]); } cout << ans << endl; return 0; }