007. Clock Seconds

Codeforces
IDCF10269007
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You have a clock that tells time in the usual way: hours, minutes, and seconds. When you wake up in the morning, you want to figure out how many seconds you slept for. Conveniently, you fell asleep the night before at exactly 12:00 AM. Remember that there are 60 seconds in a minute and 60 minutes in an hour. The first line of input contains a positive integer _h_ indicating the current number of hours displayed on the clock (_1_ <= _h_ <= _11_). The second line of input contains a positive integer _m_ indicating the current number of minutes displayed on the clock (_0_ <= _m_ <= _59_) The third line of input contains a positive integer _s_ indicating the current number of seconds displayed on the clock (_0_ <= _s_ <= _59_) The fourth line of input contains a string _a_ indicating whether it is currently the morning or the afternoon. _a_ will be either _AM_ or _PM_. You are guaranteed to have slept for less than 24 hours. Also, note that _h_ will never equal 12. Print a single positive integer _t_: the number of seconds of sleep that you got. ## Input The first line of input contains a positive integer _h_ indicating the current number of hours displayed on the clock (_1_ <= _h_ <= _11_). The second line of input contains a positive integer _m_ indicating the current number of minutes displayed on the clock (_0_ <= _m_ <= _59_) The third line of input contains a positive integer _s_ indicating the current number of seconds displayed on the clock (_0_ <= _s_ <= _59_) The fourth line of input contains a string _a_ indicating whether it is currently the morning or the afternoon. _a_ will be either _AM_ or _PM_. You are guaranteed to have slept for less than 24 hours. Also, note that _h_ will never equal 12. ## Output Print a single positive integer _t_: the number of seconds of sleep that you got. [samples]
**Definitions** Let $ h \in \mathbb{Z} $ be the current hour ($1 \leq h \leq 11$). Let $ m \in \mathbb{Z} $ be the current minute ($0 \leq m \leq 59$). Let $ s \in \mathbb{Z} $ be the current second ($0 \leq s \leq 59$). Let $ a \in \{\text{AM}, \text{PM}\} $ be the period indicator. **Constraints** 1. $ 1 \leq h \leq 11 $ 2. $ 0 \leq m \leq 59 $ 3. $ 0 \leq s \leq 59 $ 4. $ a \in \{\text{AM}, \text{PM}\} $ 5. Sleep duration < 24 hours **Objective** Compute the total seconds slept, starting from 12:00 AM: $$ t = \begin{cases} 3600h + 60m + s & \text{if } a = \text{AM} \\ 3600(h + 12) + 60m + s & \text{if } a = \text{PM} \end{cases} $$
API Response (JSON)
{
  "problem": {
    "name": "007. Clock Seconds",
    "description": {
      "content": "You have a clock that tells time in the usual way: hours, minutes, and seconds. When you wake up in the morning, you want to figure out how many seconds you slept for. Conveniently, you fell asleep th",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269007"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You have a clock that tells time in the usual way: hours, minutes, and seconds. When you wake up in the morning, you want to figure out how many seconds you slept for. Conveniently, you fell asleep th...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ h \\in \\mathbb{Z} $ be the current hour ($1 \\leq h \\leq 11$).  \nLet $ m \\in \\mathbb{Z} $ be the current minute ($0 \\leq m \\leq 59$).  \nLet $ s \\in \\mathbb{Z} $ be the current se...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments