Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

i want someone to give me an analyse about this code. so that i can make it as a report. and if you can develop

i want someone to give me an analyse about this code. so that i can make it as a report. and if you can develop it please do so

#include  #include  using namespace std; int main() { /*taking input from user*/ int m,n,k; cout<<"Enter Number of Staff Members (m) : "; cin>>m; cout<<"Enter number of working days (n) :"; cin>>n; cout<<"Enter number of minimum leaves (k) :"; cin>>k; cout<<"Enter staff Requirement: "<>a[i]; total_staff_require+=a[i]; } int total_min_leave_require = k*m; // k leaves for each m staff members if(total_staff_require+total_min_leave_require > m*n) { cout<<"Minimum k leaves not possible for each staff "; } /* number of staffs left after fulfilling min leave for each staff and min staff for each day*/ int diff = m*n - total_staff_require - total_min_leave_require; int idx=0; /* run n times in worst case */ while(idx0) { int temp = a[idx]; a[idx]+=min(diff,m-a[idx]); diff-=(a[idx]-temp); ++idx; } queue onLeave,working; /* run m times */ for(int i=0;i 

The original question is :

The original question : 

Implement an automatic shifts arrangement system. Problem description: Given m staffs and n days, find an arrangement that can satisfy (1) each staff must take at least k days off; (2) given that each day requires at least ai(1<=i<=n) staffs for working, the arrangement on each day should have more than ai staffs (when possible). Design the data structure and algorithm and analyze their complexity in the report, and note that the experiment analysis for different input size is needed. C++ language

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

LO2 Distinguish among three types of performance information.

Answered: 1 week ago