From 61a26ff0fac7320fe79261e4af0e744e984cebb3 Mon Sep 17 00:00:00 2001 From: Padmesh Sharma <100578426+PadmeshSharma@users.noreply.github.com> Date: Sat, 21 Oct 2023 20:29:02 +0530 Subject: [PATCH] Create Book Allocation Problem.cpp --- C++/Book Allocation Problem.cpp | 54 +++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 C++/Book Allocation Problem.cpp diff --git a/C++/Book Allocation Problem.cpp b/C++/Book Allocation Problem.cpp new file mode 100644 index 0000000..559a3fe --- /dev/null +++ b/C++/Book Allocation Problem.cpp @@ -0,0 +1,54 @@ +#include +using namespace std; + +bool isPossible(vector arr, int n, int m, int mid) { + int studentCount = 1; + int pageSum = 0; + //cout << "checking for mid "<< mid < m || arr[i] > mid ) { + return false; + } + pageSum = arr[i]; + } + if(studentCount > m) { + return false; + } + //cout << " for i " << i << " Student "<< studentCount << " pageSum " << pageSum << endl; + } + return true; +} + +int allocateBooks(vector arr, int n, int m) { + int s = 0; + int sum = 0; + + for(int i = 0; i