40分请看看,谢谢

P1478 陶陶摘苹果(升级版)

Nightriver @ 2017-09-15 20:29:20

var
  n,i,j,k,t,s,r,a,b:longint;
  x,y,c:array[1..100051]of longint;
begin
  read(n,s);
  readln(a,b);
  for i:=1 to n do read(x[i],y[i]);
  for i:=1 to n-1 do begin
    for j:=i+1 to n do begin
      if y[i]>y[j] then begin
        t:=y[i];
        y[i]:=y[j];
        y[j]:=t;
        k:=x[i];
        x[i]:=x[j];
        x[j]:=k;
      end;
    end;
  end;
  k:=1;
  s:=s-y[k];
  t:=1;
  while s>0 do begin
    if x[k]<(a+b) then t:=t+1;
    k:=k+1;
    s:=s-y[k];
  end;
  write(t);
end.

by SSL_lzx @ 2017-09-15 20:45:57

额,万一陶陶真的一个都摘不到,那么你t的初始化不是坏事了吗。。。


by SSL_lzx @ 2017-09-15 20:48:00

而且,你如果够得到,但是没力去摘的话,你循环里面还是会+1的说,高度和力气一起判断吧


by SSL_lzx @ 2017-09-15 20:52:05

@ ホタル(还不会洛谷的@)


by SSL_lzx @ 2017-09-15 20:52:58

@ ホタル(是这样吗)


by SSL_lzx @ 2017-09-15 20:53:19

@ホタル


|