You are viewing a single comment's thread. Return to all comments →
Too many variables? Maybe. Do I care? Absolutely not!
int workbook(int n, int k, vector<int> arr) { int problems = 0; int bookMark = 1; for(int i = 0; i<arr.size(); i++){ int pages = (arr[i] + k - 1) / k; int firs_exe = 1; int last_exe = min(firs_exe + k - 1, arr[i]); while (pages-->0) { if(firs_exe <= bookMark && bookMark <= last_exe) problems++; firs_exe = last_exe + 1; last_exe = min(firs_exe + k - 1, arr[i]); bookMark++; } } return problems; }
Seems like cookies are disabled on this browser, please enable them to open this website
Lisa's Workbook
You are viewing a single comment's thread. Return to all comments →
Too many variables? Maybe. Do I care? Absolutely not!