Company Dinner
Lili works part-time in a restaurant near her campus as a waitress. One day, a boss from a company down the street decided to hold a company dinner in the restaurant she worked at. Before the dinner, the food is arranged in a sorted order A according to their type. Moments later, the manager of the restaurant confronted Lili and asks Q questions, each one asks how many foods of type Bi are there. Lili has asked you as her friend to help her count and answer as fast as possible.
Format Input
A single line with two integers N and Q denoting the number of food and the number of question respectively, followed by a line containing N elements denoting the type of the foods and another Q lines each containing a single integer denoting the number of occurrences of the type of food asked by the manager.
Format Output
Q lines each with a single integer denoting the number of occurence of Bi
in A.
Constraints
• 1 ≤ N, Q ≤ 10^5
• 1 ≤
• Ai ≤ Aj for all 1 ≤ i ≤ j ≤ N
Sample Input 1
5 5
1 1 2 2 5
1
2
3
4
5
Sample Output 1
2
2
0
0
1
Sample Input 2
3 4
2 2 2
3
2
1
10
Sample Output 2
0
3
0
0
Sir please use C language, dont use other library except <stdio.h>, use binary search. Thx. I have code the question but when I submit it, it's time limit error, so please use binary search.
Step by stepSolved in 2 steps
- Ans p please question as code.arrow_forwardcity store sid $1001 S1002 S1003 store table True False sid n city Union Edison Newark price sell m sid 51001 51001 S1003 sell table pid product The values in the above 3 tables do NOT violate the E-R diagram. name name price Ipad 300 Iphone 550 Iphone 250 pid 1234 3456 3456 product table name Ipad Iphone Iwatcharrow_forwardQuestion 20 Unknown value can be represented in a table as O NULL O Zero O Unknown ΝΑarrow_forward
- Determine where you want to reside if you want to live in an earthquake-prone area using the earthquake hazard map.arrow_forwardlook at the table; how many students are taking biology class?arrow_forwardSUPPLIER PRODUCT ProductCode ProductnName unitPrice SupCode supCode (Number, 3) SupName (text, 20) АВC LLC (Number, 10) [Char(10)] (>0) 1111111 Calculator 10 111 111 2222222 Notebook 2.5 777 222 ХҮX LLC 3333333 Book-AI 20 222 3333 PQR LLC 4444444 Pen -2.0 222 222 AXL LLC 5555555 Pencil .500 111 Eraser .500 222arrow_forward
- A social recreation club has a system to keep track of club members, committees and activities. Each club has a registration number and a title. Several members form committee. Members are male and females. Each committee has a name, a unique number and a date, which the committee has formed. The system stores the members' unique identification number, name, address, gender, birth date and club joining date. The club forms committees for different activities. A committee controls and organizes a number of activities, each of which has a unique name, a unique number and description of the event. An event has event ID and description of the event. An activity may consist of several events. Committee publishes many online advertisements about the activities. Advertisement details are ID and a title. Draw the ER diagram to represent the above scenarioarrow_forwardKA Helge Autoparts sells new and refurbished auto parts exclusively to auto dealers. Helge purchases inventory from distributors at trade conventions. Each time Helge makes a purchase, the company records the suppliers name, address, date, specific items purchased, price paid for each, and the total amount spent. Helge later researches the inventory items to set the customer price. The company assigns an inventory number to each item purchased and records the customer price for each item. Helge buys price tags and display supplies from Alwin Incorporated, a company that sells them at all trade conventions. All inventory and supplies purchases are immediately paid for with cash or with checks from a bank account in Helge's name. All cash received from sales are also deposited to the same bank account. Several times a year Helge rents display space at dealer conventions. A deposit is always required, and the entire fee is due the day the convention starts. Helge records the deposit and…arrow_forwardPK Cus CODE PK INV NUMBER PK,FK1 INV NUMBER LINE NUMBER HEDenerates contains PK CUS LNAME CUs FNAME CUs INITIAL CUS AREACODE CUS PHONE CUS BALANCE FK1 CUS CODE INV DATE P CODE LINE UNITS LINE PRICE FK2 is found in VENDOR PRODUCT PK V CODE PK P CODE V NAME v CONTACT V AREACODE V PHONE V_STATE V ORDER P DESCRIPT P INDATE P_QOH P MIN P PRICE DISCOUNT FK1 V CODE upplies Write a SQL query to list the product code, vendor code, and vendor name for all products and includes those vendors with no matching products. Y CODE- PRODUCTY CODEarrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education