Let C = Int 100 Init to All Zeros

Let C = Int 100 Init to All Zeros

<p>Parking</p><p>Your task is to calculate parking rates based on the presence of 3 trucks in a parking lot. The number of trucks parked during any given time interval determines the rate per minute charged to each truck. You are given three rates per minute in the input. You are also given the arrival and departure times of each truck as integers beween 1 and 100.</p><p>Strategy: map an array C to the number of trucks in each lot during each time interval. let C = int[100] // init to all zeros read rate[1],rate[2],rate[3] for truck = 1 to 3 read s,e for k = s+1 to e // C[2] counts trucks between t[1] and t[2] C[k]++</p><p>Next, iterate through the C array and calculate cost equals number of trucks parked during each minute </p><p>( Cj )multiplied by the rate per minute for each truck. cost = 0 // assert: C[j] <= 3 for j = 1 to 100 cost += rate[ C[j] ] * C[j]</p>

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    1 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us