## 1. Abridged Problem Statement

Given the scheduled start time S and the actual arrival time P (both in seconds), compute how many cups of tea Andrew owes based on how late he is:

- 0 seconds late -> 0 cups
- 1 to 299 seconds late -> 1 cup
- 300 to 899 seconds late -> 2 cups
- 900 to 1799 seconds late -> 3 cups
- >=1800 seconds late -> 4 cups



## 2. Detailed Editorial

- **Read input**: two numbers S (start time) and P (arrival time).
- **Compute delay**: `delay = P - S`. The reference code keeps these as doubles and converts the delay to minutes by dividing by 60, but the comparison can equally be done in seconds.
- **Non-late case**: if `delay <= 0`, Andrew is on time or early -> owes 0 cups.
- **Threshold checks** (in minutes here):
  - If `0 < delay < 5`, less than 5 minutes -> 1 cup.
  - If `5 <= delay < 15`, between 5 and 15 minutes -> 2 cups.
  - If `15 <= delay < 30`, between 15 and 30 minutes -> 3 cups.
  - If `delay >= 30`, 30 minutes or more -> 4 cups.
- **Output** the computed number of cups.

A clean way to write the branch is to start with the largest answer (4) and lower it as more thresholds are passed, checking from the largest threshold downward.

Time complexity is O(1), memory O(1). Edge cases include P == S (exactly on time) and P < S (early arrival).



## 3. C++ Solution

```cpp
#include <bits/stdc++.h>

using namespace std;

template<typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& x) {
    return out << x.first << ' ' << x.second;
}

template<typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& x) {
    return in >> x.first >> x.second;
}

template<typename T>
istream& operator>>(istream& in, vector<T>& a) {
    for(auto& x: a) {
        in >> x;
    }
    return in;
};

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& a) {
    for(auto x: a) {
        out << x << ' ';
    }
    return out;
};

double start_time, arrival;

void read() { cin >> start_time >> arrival; }

void solve() {
    // Map the lateness (arrival minus start, in minutes) to cups of tea:
    // on time owes 0, any positive delay owes 1, 5+ minutes owes 2, 15+ owes 3
    // and 30+ owes 4. Check the thresholds from the largest downward.

    double delay = (arrival - start_time) / 60.0;

    int ans = 4;
    if(delay < 30) {
        ans = 3;
    }
    if(delay < 15) {
        ans = 2;
    }
    if(delay < 5) {
        ans = 1;
    }
    if(delay <= 0) {
        ans = 0;
    }

    cout << ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int T = 1;
    // cin >> T;
    for(int test = 1; test <= T; test++) {
        read();
        // cout << "Case #" << test << ": ";
        solve();
    }

    return 0;
}
```



## 4. Python Solution

```python
# Read two integers: S = scheduled start time, P = actual arrival time
S, P = map(int, input().split())

# Compute delay in seconds
delay = P - S

# If arrival is on time or early, no cups owed
if delay <= 0:
    print(0)
elif delay < 5 * 60:
    # less than 5 minutes late -> 1 cup
    print(1)
elif delay < 15 * 60:
    # between 5 and 15 minutes late -> 2 cups
    print(2)
elif delay < 30 * 60:
    # between 15 and 30 minutes late -> 3 cups
    print(3)
else:
    # 30 minutes or more late -> 4 cups
    print(4)
```



## 5. Compressed Editorial

Compute `delay = P - S`. If `delay <= 0` -> 0 cups. Else compare `delay` against 5 min (300 s), 15 min (900 s), 30 min (1800 s) thresholds in increasing order to assign 1, 2, 3, or 4 cups.
