题解

249 条题解

  • 0
    @ 2009-07-16 13:48:33
    1. n,m别写反;
  • 0
    @ 2009-07-15 15:30:57

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var n,m,min,j,e,i,t,k:longint; a,b:array[0..10000]of integer;

    begin

    readln(n,m);

    for i:=1 to n do readln(a[i]);

    for i:=1 to m do readln(b[i]);

    for i:=1 to m-1 do

    for j:=i+1 to m do if b[i]0 do inc(k);

    for i:=1 to n do

    begin

    for j:=1 to k do if a[i]>b[j] then

    begin

    inc(e);

    b[j]:=maxint;

    break;

    end;

    end;

    write(m-e);

    end.

  • 0
    @ 2009-07-14 20:38:33

    program aaa;

    var

    n,m,i,j,js,jl,max:longint;

    p,t:array[1..2001]of longint;

    begin

    read(n,m);

    for i:=1 to n do readln(p[i]);

    for i:=1 to m do readln(t[i]);

    js:=m;

    for i:=1 to n do

    begin

    max:=0; jl:=0;

    for j:=1 to m do

    begin

    if (t[j]0)and(max

  • 0
    @ 2009-07-14 09:57:28

    AC率不高,总的来说一是没注意”小于“(不能等);二是“负的不能摘”(可以用一个等于0的变量来判断)。

  • 0
    @ 2009-07-13 14:33:13

    晕了,没看见负的不能摘,没看见是小于,啊,怎么越来越粗心了,难怪这道题AC率不高,好阴险

  • 0
    @ 2009-06-28 21:34:22

    //苹果摘陶陶

    #include

    int Fun(int, int [], int);

    int main()

    {

    int N, M; //N表示苹果数 M表示陶陶数

    int AppleH[2000], TaoH[2000], i, j, k, Sum;

    scanf("%d %d", &N, &M);

    for(i=0; i

  • 0
    @ 2009-06-29 08:49:40

    var

    n,m,i,j,t:integer;

    a,b:array[1..2000] of integer;

    {a apple zhai

    b taotao bei zhai}

    k:boolean;

    begin

    readln(n,m);

    for i:=1 to n do

    read(a[i]);

    for j:=1 to m do

    read(b[j]);

    for i:=1 to n-1 do

    for j:=n downto i+1 do

    if a[j]>a[j-1] then

    begin

    t:=a[j-1];

    a[j-1]:=a[j];

    a[j]:=t;

    end;

    for i:=1 to m-1 do

    for j:=m downto i+1 do

    if b[j]>b[j-1] then

    begin

    t:=b[j-1];

    b[j-1]:=b[j];

    b[j]:=t;

    end;

    i:=1;

    j:=1;

    t:=0;

    while (jm+1) and (in+1) do

    begin

    if (a[i]>b[j]) and (b[j]>0)

    then

    begin

    inc(t);

    inc(i);

    inc(j);

    end

    else

    if jm+1 then inc(j);

    end;

    write(m-t);

    end.

  • 0
    @ 2009-06-14 14:06:40

    var a,b:array[1..3000] of longint;

    i,j,n,p,m:longint;

    procedure qsorta(l,r:longint);

    var i,j,m,t:longint;

    begin

    i:=l; j:=r; m:=a[(i+j) div 2];

    repeat

    while a[i]>m do inc(i);

    while a[j]

  • 0
    @ 2009-06-13 19:43:17

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    program p1291;

    const

    max=2000;

    var

    n,m,i,j,count,maxc,posi:integer;

    apples:array[1..max] of integer;

    taotao:array[1..max] of integer;

    begin

    fillchar(taotao,sizeof(taotao),0);

    fillchar(apples,sizeof(apples),0);

    readln(n,m);

    for i:=1 to n do

    readln(apples[i]);

    for i:=1 to m do

    readln(taotao[i]);

    count:=m;

    for i:=1 to n do

    begin

    maxc:=0;

    posi:=0;

    for j:=1 to m do

    if (taotao[j]>0) and (taotao[j]maxc)

    then

    begin

    maxc:=taotao[j];

    posi:=j;

    end;

    if posi0 then

    begin

    taotao[posi]:=-1;

    dec(count);

    end;

    end;

    writeln(count);

    end.

  • 0
    @ 2009-06-12 20:27:38

    program P1291;

    const

    Limit=2000;

    var

    t,p:array[1..Limit]of longint;

    n,m,max,maxp,tot:integer;

    procedure init;

    var

    i,j:Integer;

    begin

    readln(n,m);

    for i:=1 to n do

    readln(p[i]);

    for i:=1 to m do

    readln(t[i]);

    tot:=m;

    end;

    procedure main;

    var

    i,j:integer;

    begin

    for i:=1 to n do

    begin

    max:=-maxint; maxp:=0;

    for j:=1 to m do

    if (t[j]0)

    and (t[j]>max) then

    begin

    max:=t[j];

    maxp:=j;

    end;

    if maxp0 then

    begin

    dec(tot);

    t[maxp]:=0;

    end;

    end;

    writeln(tot);

    end;

    Begin

    init;

    main;

    End.

  • 0
    @ 2009-05-29 19:28:56

    通過水題我終於50了,慶祝下

  • 0
    @ 2009-05-22 17:12:30

    大家解释一下,为什么不是按照输入顺序摘,而是按照从大到小摘

  • 0
    @ 2009-04-22 17:57:42

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    var i,j,k,m,n,o,p:integer;

    a,b:array[1..2000] of integer;

    begin

    readln(n,m);

    p:=m;

    for i:=1 to n do

    readln(a[i]);

    for i:=1 to m do

    readln(b[i]);

    for i:=1 to n-1 do

    for j:=i+1 to n do

    if a[i]

  • 0
    @ 2009-04-12 15:18:23

    #include

    using namespace std;

    int n,m;

    int cmp(const void *a,const void *b)

    {

    int *aa=(int *)a;

    int *bb=(int *)b;

    return *aa>*bb?1:-1;

    }

    int y;

    int main()

    {

    cin>>n>>m;

    int ap[n+1];int tt[m+1];

    for(int i=1;i>ap[i];

    for(int i=1;i>tt[i];

    qsort(ap+1,n,sizeof(ap[0]),cmp);

    qsort(tt+1,m,sizeof(tt[0]),cmp);

    y=m;

    for(int i=n;i>=1;i--)

    {

    for(int j=y;j>=1;j--)

    {if(tt[j]=ap[i])

    {cout

  • 0
    @ 2009-04-09 20:52:03

    编译通过...

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

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

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

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

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

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

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

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

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

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

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

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

    第50道!!!!

  • 0
    @ 2009-04-01 22:46:23

    多交几次……练练各式各样的排序……

  • 0
    @ 2009-03-21 15:14:29

    发现大家很无情,没有一个人提示大家要注意什么..那就我来说下的AC的要点吧..咳咳(如果你是为刷题而来,请下降N楼找程序,WS我).我们初一的话痨病又犯了.

    要点在于:看题!!!!发现苹果不是按顺序来摘,是要按照能伸到的高度的降序顺序来摘.并且如果没有一个陶陶符合条件的话,还要加一个判断,是否要从结果里减去.好了,就说这么多,我自己WA了N遍以后才知道..55

  • 0
    @ 2009-03-17 17:50:08

    和楼下的兄弟们一样,没看清题目,用桶排序再模拟下就行了.

    program pingguo;

    var m,n,i,j,z,v:longint;

    p,b:array [-10000..10000] of longint;

    begin

    fillchar(p,sizeof(p),0);

    fillchar(b,sizeof(b),0);

    readln(m,n); z:=0;

    for i:=1 to m do

    readln(p[i]);

    for i:=1 to n do

    begin

    readln(j); if j>0 then inc(b[j]); end;

    for i:=1 to m do

    begin

    v:=0;

    repeat

    dec(p[i]);

    if b[p[i]]0 then

    begin

    dec(b[p[i]]);

    v:=1;

    end;

    until (v=1) or (p[i]

  • 0
    @ 2009-03-15 22:09:37

    不能排序。。。。、。。

    语文题啦....

  • 0
    @ 2009-03-10 22:30:48

    break很重要

信息

ID
1291
难度
6
分类
贪心 点击显示
标签
(无)
递交数
9723
已通过
2330
通过率
24%
被复制
16
上传者