SAP Labs Interview Question
Anonymous User
731

Can someone help with this ques?

Ashwin is flying to and fro  Delhi to Bombay. He is limited on money because it is month-end and hence he wants to find the cheapest k flights between the two locations.
 
Input Format
First-line contains 2 space-separated integers: N, k.
N denoting the number of flights and k denoting the cheapest k flights Ashwin needs.
 
Second-line contains the cost of the N flights from Delhi to Bombay.
Third-line contains the cost of the N flights from Bombay to Delhi.
Output Format
A single line containing the cheapest k flights
Constraints :
0 ≤ N ≤ 100000
0 ≤ k ≤ N
 
Input
5 5
2 3 4 5 6
4 6 6 10 15
 
Output
6 7 8 8 8
Comments (1)