ECOO '19 R1 P1 - Free Shirts

View as PDF

Submit solution

Points: 5 (partial)
Time limit: 30.0s
Memory limit: 512M

Problem type

Throughout the year, there are many programming events that students can attend to meet like-minded individuals, hone their skills and, most importantly, get a free t-shirt.

Ian is an avid attender of these events because he hates doing laundry. Ian only does his laundry when all his shirts are dirty, so this constant influx of shirts allows him to put off laundry for longer periods of time.

Ian starts with N clean shirts. Ian wears one clean shirt every day, after which it becomes dirty. If at the beginning of a day (before any events) Ian only has dirty shirts, then he will do the laundry, which makes all his shirts clean again. If Ian goes to an event, then he will receive one clean shirt.

Given the initial number of shirts that Ian has and the schedule of events for the next D days, how many times will Ian do the laundry in the next D days?

Input Specification

The input contains 10 datasets. Each dataset begins with three integers N, M, D (1 \le N, M \le 100, 1 \le D \le 1\,000), the initial number of shirts that Ian has, the number of events coming up, and the number of days, respectively.

The next line contains M integers A_i (1 \le A_i \le D), the days on which there are events. There may be multiple events in a single day.

Output Specification

For each dataset, output the number of times that Ian will do the laundry in the next D days.

Sample Input (Two Datasets Shown)

1 1 10
1 3 10
2 9 5

Sample Output


Explanation of Sample Datasets

In the first test, Ian does the laundry on days 2, 3, 4, 5, 6, 7, 8, 9, 10.

In the second test, Ian does the laundry on days 2, 4, 7.

Educational Computing Organization of Ontario - statements, test data and other materials can be found at


  • 0
    mehulkschool  commented on Dec. 28, 2022, 8:30 p.m.

    This one was a tricky one. I was pulling my hair out.

  • 0
    jednooki  commented on Aug. 4, 2022, 8:04 a.m.

    This took me a while. My problem was I was dirtying up a shirt a the beggining of a day :).

  • 0
    lifendead  commented on June 17, 2022, 9:24 p.m.

    My solution required to sort events list, but I did it before converting into integers. On strings it sorts differently. It took me awhile to notice this flaw.

    • 0
      ddooling  commented on June 9, 2023, 10:53 p.m.

      Ah yes! me too. only realized it because of your comment. thank you!

  • 0
    solverbot  commented on April 21, 2022, 9:25 a.m.

    Ian will launder "ALL" his shirts on laundry day... Realized the importance of attention to details...

  • 1
    CoolHand  commented on April 6, 2022, 3:50 p.m.

    2 things really tripped me up on this, more then the fact that you can have multiple competitions in one day.

    • The inputs are one one line, not each line.
    • Remember to update the # of datasets if you are testing with fewer. :-)

  • 6
    whammydiver  commented on March 25, 2022, 1:53 a.m.

    REMEMBER - multiple competitions CAN occur on a single day. More than one shirt must be added to the total if this is the case.

    Debugging took me over an hour!

    If adding a single shirt, you'll probably score 9/10 on both test patterns.

    • 0
      valkyrie17  commented on Feb. 18, 2023, 9:46 a.m.

      Thank you, that was it!

    • 0
      HopefulCreator  commented on Aug. 19, 2022, 6:40 a.m.

      It would be nice if that was mentioned as a possibility, thanks for saving me so much time!

    • 0
      hirtal  commented on July 25, 2022, 8:07 a.m.

      multiple competitions... I didn't think that. thank you!!!

  • 0
    Jzaragoza98  commented on March 22, 2022, 6:41 p.m. edited

    Unsure what my mistake is on this problem. I am getting 90/100 but cannot identify my issue.

    Figured it out. Make sure you account for event being on same day