OpenJudge

13:拦截导弹

  • scholar
    scholar 15.11.2 回复

    我的测试结果和例题完全一致,请帮忙查看下为何提交时老是说结果错误

    #include "stdio.h"
    #include "iostream"
    using namespace std;

    int main(){
    int n, ptr[25];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> ptr[i];
    int * d = new int[n];
    d[n-1] = 1;
    for (int i = n - 2; i >= 0; i--){
    d[i] = 1;
    for (int j = i + 1; j < n; j++){
    if ((ptr[j] <= ptr[i])&(d[i] < d[j] + 1))
    d[i] = d[j] + 1;
    }
    }
    cout << d[0] << endl;
    delete[] d;
    }

想要评论吗?

注册OpenJudge账号,如果您已经注册,请先登入