Scoring in Exam
Practice
3.6 (330 votes)
Approved
Easy
Ready
Sorting
Problem
69% Success 7053 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Milly is at the examination hall where she is reading a question paper. She checked the question paper and discovered that there are N questions in that paper. Each question has some score value. Ideally it's like questions requiring more time have more score value and strangely no two questions on the paper require same time to be solved.
She is very excited by looking these questions. She decided to solve K questions while maximizing their score value. Could you please help Milly to determine the exact time she needs to solve the questions.
Input
- First line of input contains two space separated integers N and Q, where N is the number of questions available and Q is number of queries
- Next line contains N space separated integers denoting the time Ti of N questions
- Next line contains N space separated integers denoting the scores Si of N questions
- Next Q lines contains a number K each, the number of questions she wants to solve
Output
- Print the time required for each query in a separate line.
Constraints
1 <= N <= 1051 <= Q <= 105
1 <= K <= N
1 <= Ti, Si <= 109
Submissions
Please login to view your submissions
Similar Problems
Points:30
16 votes
Tags:
AlgorithmsCounting and ArrangementsDivide-and-conquer algorithmMerge SortMerge sortSorting
Points:30
21 votes
Tags:
AlgorithmsArraysEasyGreedy AlgorithmsMerge sortSorting
Points:30
10 votes
Tags:
ApprovedEasyMathOpen
Editorial