小编Rav*_*mar的帖子

为什么我的代码无法处理大数组输入(> 10000)?

int n;//input size of array
cin >> n;
vector <int> a(n);
vector <int> in;

for (int i = 0; i < n; i++)
    cin >> a[i];//input array elements
if (n == 1) {
    cout << "1" << "\n";
    return 0;
}

for (int i = 1; i <= n ; i++)//to get longest incresing subsequence in the array
{
    int flag = 0, j = i;

    while (j < n && a[j] >= a[j - 1] ) {
        j++;
        flag …
Run Code Online (Sandbox Code Playgroud)

c++ vector undefined-behavior subscript-operator

2
推荐指数
1
解决办法
103
查看次数