Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int workbook(int n, int k, vector<int> arr) {
- int result=0;
- int pages=1;
- for (int i=0; i<n; i++){
- int num_Prob = arr[i];
- int cur_Prob=1;
- do{
- if (num_Prob-k<0){
- if (cur_Prob!=1){if((cur_Prob<=pages)&&(arr[i]>=pages))result++;}
- else if((cur_Prob<=pages)&&(num_Prob>=pages))result++;
- }
- else if ((cur_Prob<=pages)&&((cur_Prob+k)>pages)) {
- result++;
- }
- cur_Prob+=k;
- pages++;
- num_Prob-=k;
- }while (num_Prob>0);
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement