题解

303 条题解

  • -1
    @ 2006-08-21 15:13:47

    纪念一下

    编译通过...

    ├ 测试数据 01:答案正确... 0ms

    ├ 测试数据 02:答案正确... 0ms

    ├ 测试数据 03:答案正确... 0ms

    ├ 测试数据 04:答案正确... 0ms

    ├ 测试数据 05:答案正确... 0ms

    ├ 测试数据 06:答案正确... 0ms

    ├ 测试数据 07:答案正确... 0ms

    ├ 测试数据 08:答案正确... 0ms

    ├ 测试数据 09:答案正确... 0ms

    ├ 测试数据 10:答案正确... 0ms

    ---|---|---|---|---|---|---|---|-

    Accepted 有效得分:100 有效耗时:0ms

  • -2
    @ 2017-01-22 15:23:12
    #include <iostream>
    #include <cmath>
    #include <algorithm>
    #include <cstdio>
    #include <cstring>
    
    using namespace std;
    const int N=200;
    int a[N],b[N];
    int l[N],r[N];
    int d[N],g[N];
    int main()
    {
        int n;cin>>n;
        for(int i=1;i<=n;i++)
            scanf("%d",&a[i]),l[i]=r[i]=1;
        memset(g,63,sizeof(g));
        for(int i=1;i<=n;i++)
        {
            int k=lower_bound(g+1,g+n+1,a[i])-(g+1);
            l[i]=k+1;
            g[k+1]=a[i];
        }
        memset(g,63,sizeof(g));
        for(int i=n;i>=1;i--)
        {
            int k=lower_bound(g+1,g+n+1,a[i])-(g+1);
            r[i]=k+1;
            g[k+1]=a[i];
        }
        int maxv=0;
        for(int i=1;i<=n;i++)
            maxv=(max(maxv,l[i]+r[i]-1));
        cout<<n-maxv<<endl;
        return 0;
    } 
    
  • -2
    @ 2016-10-28 18:23:53

    利用动归,求两次
    program jj;
    var a,b,c:array[1..100]of integer;
    max,n,i,j:integer;
    begin
    // assign(input,'in.txt'); assign(output,'out.txt');
    //reset(input);rewrite(output);
    readln(n);
    for i:=1 to n do
    begin
    read(a[i]);b[i]:=1;c[i]:=1;
    end;
    for i:=1 to n do
    begin
    for j:=1 to i-1 do
    if (a[i]>a[j])and (b[i]<=b[j]) then
    b[i]:=b[j]+1;
    end;
    for i:=n downto 1 do
    begin
    for j:=n downto i+1 do
    if (a[i]>a[j])and (c[i]<=c[j]) then
    c[i]:=c[j]+1;
    end;
    max:=0;
    for i:=1 to n do
    if (c[i]+b[i]>max) then
    max:=c[i]+b[i];
    writeln(n-max+1);
    //close(input);close(output);
    end.

信息

ID
1098
难度
5
分类
动态规划 | LIS 点击显示
标签
递交数
12819
已通过
4882
通过率
38%
被复制
20
上传者