
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

- city 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_forwardDefine users, giving the three groups of users there are.arrow_forward
- KA 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_forwardStudents: Johnson, Williams, Matt, Jones, Eric, Lili, John and Jason, whose grades are listed below. Each column is the grades each student received. There are 8 students with 10 grades each. Johnson: 79, 92, 85, 0, 100, 64, 72, 99, 90, 86 Williams: 80, 75 93, 94, 0, 90, 89, 88, 87, 86 Matt: 82, 67, 72, 74, 89, 0, 70, 89, 100, 76 Jones: 85, 84, 82.5, 82, 84, 80, 80.5, 90, 96, 85 Eric: 90, 91, 87, 85.5, 86.5, 0, 90, 90, 91, 92 Lili: 60, 75, 81, 70, 80, 81, 94, 67.5, 99, 98 John: 79,0, 74, 96, 88.5, 88, 0, 100, 86, 83 Jason: 89, 90, 90, 85, 85, 90, 91, 88, 100, 79 Write user-defined functions or build-in functions (e.g., sum, mean, max, min, etc.) to calculate: The Average Grade of each student; this average should be a vector. The average of the class; this average is a scalar vector. The highest grade among the Average Grade of Each Student The lowest grade among the Average Grade of Each Student Show a table with each student's name, average grade and letter score using A, B, C, D, F…arrow_forwardLook up student MAJOR and ROOM information based on the student NAME. Enter formula into B2. 1 NAME MAJOR ROOM 2 58 3 4 NAME MAJOR ROOM 5 $1 CIS DBH 6 S2 7 3 A/F DBH A/F DBH 8 $4 мом SCI 9 S5 мом DBH 10 56 CIS SCI 11 S7 CIS DBH 12 S8 A/F 13 S9 мом 14 S10 CIS Size Color Price Item T. 15 Size L T M 16 Color R. 17 Price 28 H. 29 30 XL R. 18arrow_forward
- Estem.org/courses/64525/assignments/9460783?module_item_id=18078917 The following information can help you get started: • Invitation Details: it boils down to when and where o When: Time and date • Where: Address • Invitee List: Name and email • Name: First Name, or First Name and Last Name Email: Email address . Other considerations: After you complete your invitation, answer the following questions: 1. What type of data are time, date, and place? How are they different from the other data types on the invite and guest list? F4 A Additional information worth including: dress code, directions, gifting, how to contact you. . How will you know who is showing up? RSVP? . Is there a theme to your invitation/design? x F5 % F6 F7 DELL F8 F9 ROMNA F10 F11 PrtScrarrow_forwardA fast food restaurant is planning to develop a system to process customer’s orders. The system receives food orders from the users, and stores and processes according to the order in which the users placed the orders. The system can remove an order from the list of orders once the order is complete. The system can also display the order which is currently being processed by the employees. The system displays the list of orders as well. The system displays all these options as a menu of choices to a user and performs the operations according to the user’s selection. (Please see the test runs on the next page). Write a program in C/C++ to develop a simple order processing system for the fast-food restaurant. In your program, you must use queue to store and process customer’s orders. Your program must use a linked list to perform the queue operations. Your output format should be as shown in the test runs (see the next page). Your program must contain the following user-defined…arrow_forwardNormalize the following table to the 3rd Normal form: Student Student Phone Course Term Grade Instructor Instructor Phone Lauren Fernell 555-7771 MIS 350 F12 A Hess 555-2222 Lauren Fernell 555-7771 MIS 372 F12 B Sarker 555-2224 Lauren Fernell 555-7771 MIS 426 F12 A Fuller 555-2227 Lauren Fernell 555-7771 MIS 375 F12 B+ Wells 555-2228 Brigit Schnieder 555-2215 MIS 350 F12 A Hess 555-2222 Brigit Schnieder 555-2215 MIS 375 F12 B+ Wells 555-2228 Brigit Schnieder 555-2215 MIS 372 F12 A Sarker 555-2224 Brigit Schnieder 555-2215 MIS 374 F12 B Clay 555-2221 Jackie Judson 555-1245 MIS 350 F12 A Hess 555-2222 Jackie Judson 555-1245 MIS 372 F12 B+ Sarker 555-2224 How many tables did you create after normalizing the table? List each of…arrow_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





