tyvj P1279 - 柠檬超市
巨好听的~~~方大同的
P1279 - 柠檬超市From sillycross Normal (OI) 总时限:10s 内存限制:128MB |
||||||||
|---|---|---|---|---|---|---|---|---|
|
||||||||
Delphi语言: 高亮代码由发芽网提供
program tyvj1279;
type node=record
s:extended;p:longint;
end;
var c,w:array[1..100000] of longint;
a:array[1..100000] of node;
n,s,i:longint;
procedure qsort(head,tail:longint);
var i,j:longint;x:node;
begin
i:=head;j:=tail;x:=a[i];
while i<j do begin
while (i<j) and(a[j].s>=x.s) do dec(j);
a[i]:=a[j];
while (i<j)and(a[i].s<=x.s) do inc(i);
a[j]:=a[i];
end;
a[i]:=x;
if head<i-1 then qsort(head,i-1);
if tail>i+1 then qsort(i+1,tail);
end;
begin
readln(n,s);
for i:=1 to n do begin
readln(w[i],c[i]);
a[i].s:=w[i]/c[i];
a[i].p:=i;
end;
qsort(1,n);
for i:=n downto 1 do
if c[a[i].p]<=s then begin
writeln(a[i].p);
halt;
end;
end.
浙公网安备 33010602011771号