BGMI2 EDITORIAL

PROBLEM LINK

PREREQUISITES:
SORTING, ARRAYS,GREEDY

EXPLANATION
Given two arrays where array ‘a’ corresponds to bullets and array ‘b’ corresponds to damage
and we need to output minimum bullets to defeat the enemy where the enemy’s health is given by K, so to solve this we can use Greedy Approach, initially take count as 0, this count stores number of bullets required, sort the arrays based on damage in decreasing order and now iterate over sorted array ‘b’ and each time we update count as count+=min(((k+b[i]-1)/b[i]),a[i]) and reduce the health of enemy to k-=b[i]*(min((k+b[i]-1)/b[i]),a[i]) (NOTE k+b[i]-1/b[i] is used to find CEIL Of that value) (i.e damage per bullet * number of bullets)
and if health is less than 0 we output the count

SOLUTION LINK