Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
101312 王子毅 导弹拦截问题 C++ Wrong Answer 1 MS 272 KB 722 2024-12-14 19:54:36

Tests(0/10):


Code:

#include <iostream> #include <vector> #include <algorithm> using namespace std; int lengthOfLIS(vector<int>& nums) { if (nums.size() == 0) return 0; vector<int> dp(nums.size(), 1); int maxLength = 1; for (int i = 1; i < nums.size(); i++) { for (int j = 0; j < i; j++) { if (nums[i] > nums[j]) { dp[i] = max(dp[i], dp[j] + 1); } } maxLength = max(maxLength, dp[i]); } return maxLength; } int main() { int n; cin >> n; vector<int> heights(n); for (int i = 0; i < n; i++) { cin >> heights[i]; } int result = lengthOfLIS(heights); cout << result << endl; return 0; }


Run Info:

------Input------
123 256 369 213 456 956 23 698 1236 321 500 666
------Answer-----
6
------Your output-----
5