diff --git a/C++/paintersPartition.cpp b/C++/paintersPartition.cpp new file mode 100644 index 0000000..89f9f41 --- /dev/null +++ b/C++/paintersPartition.cpp @@ -0,0 +1,62 @@ +/* +Given n boards of different lengths represented by an array arr of size n, and m painters, + you need to determine the minimum amount of time required to paint all the boards. Each painter paints a contiguous segment of boards. + Constraints: + +A painter can only paint continuous segments of boards. +Each painter takes the same amount of time to paint a unit length of the board. +You have to minimize the maximum time taken by a painter to paint their assigned boards. +Input: +An integer n representing the number of boards. +An integer m representing the number of painters. +An array arr[] of size n, where each element arr[i] represents the length of the i-th board. +Output: +Return the minimum time required to paint all the boards such that no painter is overloaded with work. +*/ + +#include +#include +#include +using namespace std; + +bool isPossible(vector&arr, int n, int m, int maxAllowedTime){ + int painter = 1, time = 0; + for(int i=0; i &arr, int n, int m){ + int sum =0, maxVal = INT_MIN; + for(int i=0; iarr = {40,30,10,20}; + int n = 4, m =2; + cout<