HDU 1861 Boat Rental (simulated problem, water)

Source: Internet
Author: User

Test instructions

Existing Park Boat Rental office please write a chartering management system.

When the visitor chartering, the administrator enters the ship number and presses the S key, the system starts the time, when the visitor also ships, the administrator enters the ship number and presses the E key, the system ends the timing.

The ship number is a positive integer not exceeding 100. When the administrator enters 0 as the ship number, it means that one day the chartering work is finished, the system should output the number of visitors and the average chartering time of the day.

Note: The system should be able to automatically ignore such an invalid record because the line occasionally fails and may have incomplete records, that is, only if the ship is not in the boat, or if the ship does not have a chartering record.

Input:

The test input contains several test cases, each of which is a full-day charter record in the form
Ship number (1~100) key value (s or e) occurrence time (hours: minutes)
Each day's records are guaranteed to be given in the order of time increments. When the ship number 1 is read, all inputs are completed and the corresponding results are not output.

Output:

Output 1 rows For each test case, that is, the number of visitors to the day and the average chartering time (in minutes, an integer time in units of digits).

Code:

intmp[ the];intboat[ the];intMain () {intCountt =0; intTimetot =0; intS,hour,minute; Charkind; MEM (MP,0);  while(SCANF ("%d", &s), s!=-1) {GetChar (); scanf ("%c",&kind); scanf ("%d:%d",&hour,&minute); intTiming = hour* -+minute; if(s==0){            if(countt!=0) printf ("%d%d\n", Countt, (int)((Double) timetot/countt+0.5)); Elseprintf ("0 0\n"); Countt=0; Timetot=0; MEM (MP,0); }Else{            if(mp[s]==0){                    if(kind=='S') {Mp[s]=7; Boat[s]=timing; }            }Else{                if(kind=='E') {Mp[s]=0; ++Countt; Timetot+ = (Timing-Boat[s]); }            }        }    }    return 0;}

HDU 1861 Boat Rental (simulated problem, water)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.