## Algorithm

Problem Name: beecrowd | 2003

# Sunday Morning

By Thalyson Nepomuceno, UECE Brazil

Timelimit: 1

Sunday is market day. Early in the morning many people move to the Parangaba square where happens a fair, known to be the largest in the city. At the fair the Parangaba you can find everything.

Every Sunday, Bino make purchases at the fair. He always mark with his friend Cino, they met at the bus terminal of Parangaba at 8 am to go together to buy at the fair. But often Bino wake up too late and is late for the meeting with his friend.

Knowing that Bino takes 30-60 minutes to reach the terminal. Tell the maximum delay Bino.

## Input

The input consists of multiple test cases. Each case contains a single line containing a time H (5:00 ≤ H ≤ 9:00) that Bino woken up. The input ends with the final file (EOF).

## Output

For each test case, print "Atraso maximo: X" (without quotes), X indicates the maximum delay (in minutes) of Bino in the encounter with Cino.

 Input Sample Output Sample 7:10 5:00 Atraso maximo: 10 Atraso maximo: 0

## Code Examples

### #1 Code Example with C Programming

```Code - C Programming```

``````
#include <stdio.h>

int main(void) {
int a,b,n;
char aa;
while(scanf("%d %c %d",&a,&aa,&b) != EOF){

printf("Atraso maximo: ");
if(a < 7 || (a == 7 && b == 00))
printf("0\n");
else
printf("%d\n",(a-7)*60 + b>;
}
return 0;
}
``````
Copy The Code &

Input

cmd
7:10 5:00

Output

cmd
Atraso maximo: 10 Atraso maximo: 0

### #2 Code Example with C++ Programming

```Code - C++ Programming```

``````
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b;
char c;
while(cin >> a >> c >> b)
{
int A = a-7;
int B = b;
if(A < 0)cout << "Atraso maximo: 0\n";
else{
printf("Atraso maximo: %d\n",(A*60)+b>;
}
}
return 0;
}
``````
Copy The Code &

Input

cmd
7:10 5:00

### #3 Code Example with Javascript Programming

```Code - Javascript Programming```

``````
const { createReadStream } = require("fs")
const { createInterface } = require("readline")

//// READING FILE | STREAMS ////
/**
* @param {import("fs").PathLike} path
* @param {BufferEncoding} encoding
*/
static createReadLineInterface(path, encoding = "utf8") {
encoding: encoding,
flags: "r",
emitClose: true,
autoClose: true
}

return createInterface({
crlfDelay: Infinity,
terminal: false
})
}

/**
* @param {import("fs").PathLike} path
* @param {BufferEncoding} encoding
*/
static create(path, encoding) {

let EOF = false

const nextLineGenerator = (async function* () {
for await (const line of RLI)
yield line
})()

RLI.once("close", () => { EOF = true })

return {
hasNextLine: () => !EOF,
nextLine: async (/** @type {unknown} */ fn) => {
const { value } = (await nextLineGenerator.next())
return (typeof fn === "function") ? fn(value) : value
},
close: () => RLI.close()
}
}
}

const calcMaximumDelayTime = (hours, minutes) => (hours >= 7) ? ((hours - 7) * 60) + minutes : 0

async function main() {
const PATH = "/dev/stdin"
const ENCODING = "utf8"

const helper = (line = "") => line.split(":", 2).map(value => Number.parseInt(value, 10))

const output = []

const [hour, min] = await nextLine()
if (Number.isNaN(hour) || Number.isNaN(min)) break // EOF
output.push(`Atraso maximo: \${calcMaximumDelayTime(hour, min)}`)
}

console.log(output.join("\n"))
}

main()
``````
Copy The Code &

Input

cmd
7:10 5:00

### #4 Code Example with Python Programming

```Code - Python Programming```

``````
while True:
try:
hora = input().split(':')
n = int(hora[0])*60 + int(hora[1]) - 420
if n < 0:
n = 0
print('Atraso maximo: %d' % n)

except EOFError:
break
``````
Copy The Code &

Input

cmd
7:10 5:00

Output

cmd
Atraso maximo: 10 Atraso maximo: 0