Practice on Toph

Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Estimation of Techboy

By Mahir92 · Limits 1s, 512 MB

Techboy works in a software company. He codes in Node.js and React. Every now and then he has to give estimation for his upcoming tasks. Last week, his boss gave him a list of works to do and Techboy has given him estimated hours for each of them to finish. And he has to finish them sequentially.

There were N number of tasks. According to Techboy’s estimation, it was supposed to take Ei (1 ≤ i ≤ N, 1 ≤ Ei ≤ 10^5) hours to complete the ith task. Summation of all Ei is less than or equal to 106.

At last Techboy’s work is completed. He has finished all the tasks (Which is rare!). But not all of them matched the estimated hour. It took Ai (1 ≤ i ≤ N, 1 ≤ Ai ≤ 105) amount of hour to finish the ith task actually. Summation of all Ai is less than or equal to 10^6. But now the question is, has he managed to satisfy the management with his work?

The answer to the question is - at every Kth hour (1 ≤ K ≤ 105), Techboy’s boss will check if the number of tasks completed so far is less than the number of tasks that was estimated to be completed at that time. If that happens even for once, management will not be satisfied even if Techboy finishes all the tasks within total estimated hour.


The first input is an integer T (1 ≤ T ≤ 100), denoting the number of test cases. Each test case contains 3 lines. The first line contains two integers N and K. The next line contains N (1 ≤ N ≤ 100) numbers denoting the estimated hours. The last line will also contain N numbers denoting the actual hours it took Techboy to complete the tasks.


There will be T lines of output. Each line will contain YES if management is happy or NO if it’s not.


5 5
10 5 7 4 12
9 6 8 4 10
2 5
11 10
15 8
2 5
11 10
15 11



75% Solution Ratio

RenegadesEarliest, Jan '18

steinumFastest, 0.0s

steinumLightest, 786 kB

steinumShortest, 419B


Login to submit

Toph uses cookies. By continuing you agree to our Cookie Policy.