ECOO '21 P1 - Many Messages

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type

Theodore likes to keep in touch with his friends at all times, even when he does homework. Unfortunately, sending and receiving a lot of messages from his friends has caused him to be distracted from doing his very important math homework.

To remedy this issue, Theodore has decided to only check his messages at set intervals of time, starting at some minute. For example, starting at minute 1, Theodore might decide that he wants to check his messages every 30 minutes. Given this set interval the first time he checks his messages will be at minute 31. While studying, Theodore only accounts for the minutes he spends on his homework, disregarding the typical clock format of telling time. Theodore starts his homework at a certain time and decides to check his messages three times, separated by an interval.

Larry sends Theodore a message some time later. Given the interval Theodore uses to checks his messages, when will he read Larry's message?

Input Specification

The first line of input will consist of a single integer, the minute that Theodore starts doing his homework at.

The next line of input will consist of a single integer, the interval that Theodore wants to check his messages at.

The last line of input will consist of a single integer, the minute when Larry sent Theodore a message.

All integers in the input will be between 1 and 100.

For 30\% of the points, Larry will always send his message after Theodore last checked his phone.

Output Specification

Output the first time when Theodore will see Larry's message. If Larry's message is sent after the last time Theodore checks his phone, output Who knows....

Sample Input 1

1
30
91

Sample Output 1

91

Explanation for Sample Output 1

The first time Theodore decides to check his messages is exactly 30 minutes after minute 1, 30 + 1 = 31.

The second time Theodore checks his messages is 30 minutes after the first time, 31 + 30 = 61.

The third time Theodore checks his messages is 30 minutes after the second time, 61 + 30 = 91.

Larry sends his message just as Theo checks his messages for the last time at 91 minutes.

Sample Input 2

5
19
4

Sample Output 2

24

Explanation for Sample Output 2

Theodore will see Larry's message the first time he checks them, at 5 + 19 = 24 minutes.

Sample Input 3

2
10
99

Sample Output 3

Who knows...

Comments


  • 0
    hitechpanchal  commented on Sept. 29, 2024, 7:02 a.m. edit 5

    Can anyone suggest what mistake i have been doing here?

    I can pass the test solution provided, but cannot pass the test cases after submission

    start_homework = int(input())
    check_message_interval = int(input())
    message_sent = int(input())

    ....Finally am able to solve this after so many attempts


  • 0
    mrap  commented on May 16, 2024, 7:53 p.m. edited

    What am I missing?? The 3 samples work fine, but the judge fails on Batch 2, Case 3 (Side question: does a failed case always stop the process? I.e. not further cases are tested?)

    s = int(input())
    c = int(input())
    m = int(input())
    
    cktime1 = (s + c)
    cktime2 = s + 2 * c
    cktime3 = s + 3 * c
    
    if m > cktime3:
       print('Who knows...')
    elif m > cktime2:
        print(cktime3)
    elif m > cktime1:
        print(cktime2)
    elif m < cktime1:
        print(cktime1)
    else:
        print('Who knows...')
    

    • 0
      Sam629566  commented on May 16, 2024, 8:23 p.m.

      I suggest using the <= operator instead, so you can compare if m <= cktime1, cktime2, cktime3.

      Also for batches, I'm pretty sure that if you don't pass a test case in a batch it just terminates that batch and then jumps to the next one.


  • 1
    19oliverabbott  commented on Dec. 12, 2023, 8:47 a.m. edited

    this works with all the test data but not the solution data for some reason? any ideas

    # gets inputs
    start = int(input())
    check = int(input())
    sends = int(input())
    done = False
    
    time = start + check
    
    if time >= sends:
        print(time)
        done = True
    
    time = time + check
    if time >= sends and done == False:
        print(time)
        done = True
    
    time = time + check
    if time >= sends and done == False:
        print(time)
        done = True
    
    if done == False:
        print("Who Knows... ")
    

  • 1
    darthvader2021  commented on Nov. 9, 2023, 9:20 p.m.

    Hi, I think the condition is that he checks only 3 times. so any message after the 3rd time is outputted as "who know ..."


  • 2
    fawkeskc  commented on Oct. 4, 2022, 4:50 a.m.

    Anyone having trouble getting this to work? I can only get 30 points and can't figure out what I'm missing.