Answered step by step
Verified Expert Solution
Question
1 Approved Answer
https://github.com/Andrewrockss/callcenter I need it to pass for 5 seconds each test, I will rate. Input: The first line of input consists of two integers n
https://github.com/Andrewrockss/callcenter
I need it to pass for 5 seconds each test, I will rate.
Input: The first line of input consists of two integers n and q. Here, 1sn s 86,400 is the number of seconds your call center is open for each day and 1 sqs 50,000 is the number of queries you want to make The next line contains n integers, each between 0 and 100. Consecutive integers will be separated by a single space. The ith integer on this line indicates how many new calls were received by your call center yesterday in the ith second of operation. Finally, q lines follow. Each consists of two integers 1 ssstsn separated by a single space Output: consists of q lines, one for each query. For each query with integers s, t, you should output the total number of calls your call center received yesterday between the sth and tth second of operation (including the calls received exactly at second s and at second t) Sample Input 1 13 7 53|3 1 4 3 12 1e017 1 3 1 4 1 13 2 7 8 11 Sample Output 1 21 21 59 13 21 16 The code I made is not fast enough. What can I do to make it faster? Any suggestions would help, and any explanation as to why this is not fast and anything that would make it faster Here is a GitHub repository with the test center # read the first line n, qlist(map(int, input().split))) # read the calls calls-[int(i) for i in input().split)] s-array , t-array -D, # read and process each query for i in (range (e,q)): s,t list (map(int, input().split))) s_array.append (s) t_array.append (t) #print the answer sorting = {} #empty dictionary #how many quaries between eacth s and t array for i in range(e, q): sorting[i]-sum(calls[s_array[i] - 1:t_array[i]]) for k, v in sorting.items ): print(v) pythonStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started