Algorithm


Problem Name: beecrowd | 3147

Problem Link: https://www.beecrowd.com.br/judge/en/problems/view/3147

The Battle of the Five Armies

 

By Samuel Eduardo da Silva, IFSULDEMINAS/UFF BR Brazil

Timelimit: 1

Summarizing the story so far, we had fights with spiders, trolls, orcs, wargs, escapes in barrels and a lot of fighting with the dragon Smaug. After Smaug was defeated, the dwarves claimed the Lonely Mountain and all its riches. However, the humans who live near the mountain were responsible for defeating Smaug, and they want some of the wealth as well. Some mountain riches also belonged to elves, and they also want to claim their share.

Thorin, the leading dwarf of the adventure, becomes greedy for mountain gold and loses his sanity, thus waging a war against humans and elves.

What none of them expected was that the orcs and wargs were also ogling the mountain, and they came by surprise. Thus, humans, elves and dwarves (the good side) have to unite to fight the orcs and wargs (the evil side), thus waging the Battle of the Five Armies.

Bilbo, our hero so far, abstains from this battle, as this one has taken on proportions too big for a hobbit, however, he manages to estimate who will win. In this case, just add the number of armies on each side and check which is the largest. However, Bilbo knows that Gandalf has a plan b if the armies of men, elves and dwarves lose or draw, and that plan is to call the army eagles, thus increasing the number of the good army.

Calculate for Bilbo who will win The Battle of the Five Armies.

Ah, and if even with the eagles the two great armies tie, Bilbo will be there with his Sting sword, to destroy the last orc or warg.

 

Input

 

It contains 6 integers, H, E, A, O, W and X, representing the number of the army of humans, elves, dwarves, orcs, wargs and eagles, respectively.

 

Output

 

If the good side wins: “Middle-earth is safe.”, If not, “Sauron has returned.”.

 

 

 

Input Samples Output Samples

1 2 3 10 2 7

Middle-earth is safe.

 

 

 

1 2 3 10 2 5

Sauron has returned.

 

Code Examples

#1 Code Example with Javascript Programming

Code - Javascript Programming


const { readFileSync } = require("node:fs")
const [H, E, A, O, W, X] = readFileSync("/dev/stdin", "utf8")
	.split(" ", 6)
	.map(value => Number.parseInt(value, 10))

console.log(
	(H + E + A + X) >= (O + W) ? "Middle-earth is safe." : "Sauron has returned."
)

Copy The Code & Try With Live Editor

Input

x
+
cmd
1 2 3 10 2 7

Output

x
+
cmd
Middle-earth is safe.

#2 Code Example with Javascript Programming

Code - Javascript Programming


var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var lines = input.split('\n');
const [h, e, a, o , w, x] = lines.shift().split(" ")

if((parseInt(h) + parseInt(e) + parseInt(a) + parseInt(x) ) >= (parseInt(o) + parseInt(w))){
  console.log("Middle-earth is safe.");
}
else{
  console.log("Sauron has returned.");
} 
Copy The Code & Try With Live Editor

Input

x
+
cmd
1 2 3 10 2 7

Output

x
+
cmd
Middle-earth is safe.

#3 Code Example with Python Programming

Code - Python Programming


h,e,a,o,w,x=map(int,input().split())
bem = h+e+a+x
mal = o+w
print("Middle-earth is safe.") if bem>=mal else print("Sauron has returned.")

Copy The Code & Try With Live Editor

Input

x
+
cmd
1 2 3 10 2 7

Output

x
+
cmd
Middle-earth is safe.
Advertisements

Demonstration


Previous
#3146 Beecrowd Online Judge Solution 3146 Riddles in the Dark Solution in C, C++, Java, Js and Python
Next
#3157 Beecrowd Online Judge Solution 3157 Long Live Science! Solution in C, C++, Java, Js and Python