program P302B;
const
maxN=100000;
maxM=100000;
var s:array[0..maxN] of longint;
n,m,x,i:longint;
function BinarySearch(x:longint):longint;
var l,r,mid:longint;
begin
l:=1; r:=n;
repeat
mid:=(l+r) div 2;
if(s[mid-1]<x) and (x<=s[mid]) then exit(mid)
else
if (x>s[mid]) then l:=mid+1
else r:=mid-1;
until False;
end;
procedure nhap;
var i,c,t:longint;
begin
read(n,m);
s[0]:=0;
for i:=1 to n do
begin
read(c,t);
s[i]:=s[i-1]+c*t;
end;
end;
procedure giai;
var i:longint;
begin
for i:=1 to m do
begin
read(x);
writeln(BinarySearch(x));
// writeln(bs(x,1,n));
end;
end;
begin
assign(input,'song.inp');reset(input);
assign(output,'song.out');rewrite(output);
nhap;
//for i:=0 to n do write(s[i],' ');
//writeln;
giai;
end.
* Chuyên dạy lập trình ONLINE cho học sinh THCS, THPT *.
Mọi giao lưu, trao đổi, xin liên hệ: Lê Quang Vinh - zalo: 037.803.8755.
Page: Lớp học Code Sky
Group FB1: Ôn thi HSG9 - THTB - TS10 chuyên tin
Group FB2: Học Scratch - Ôn thi Tin học trẻ bảng A
Thứ Hai, 9 tháng 5, 2022
SONG PASCAL
Đăng ký:
Đăng Nhận xét (Atom)
Không có nhận xét nào:
Đăng nhận xét
Lưu ý: Chỉ thành viên của blog này mới được đăng nhận xét.