Here i proposed an algorithm. correct me if i am wrong !!
int main()
{
int N; //number of boards
int W; // number of workers
int smax = 0;
cin >> N >> W;
int *A = new int[N];
for(int i=0;i<N;i++){
cin >> A[i];
smax += A[i];
}
int m = *max_element(A ,A+N);
for(int i=m;i<=smax;i++){
int sum = 0;
int w = 1;
for(int j=0;j<N;j++){
if(sum+A[j] <= i){
sum += A[j];
}
else{
sum = A[j];
w++;
}
}
if(w<=W){
cout<< i<< "\n";
break;
}
}
return 0;
}
rajat ahuja wrote:
> You have to paint N boards of length {B1, B2, B3… BN}. There are K painters
> available and you are also given how much time a painter takes to paint 1
> unit of board. You have to get this job done as soon as possible under the
> constraints that any painter will only paint continuous sections of board,
> say board {2, 3, 4} or only board {1} or nothing but not board {2, 4, 5}.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.