-
Notifications
You must be signed in to change notification settings - Fork 0
/
151B.rb
47 lines (47 loc) · 808 Bytes
/
151B.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
n=gets.to_i
shop=[]
taxi=[]
max=[0,0,0]
10.times{|k|
taxi.push(k.to_s*6)
}
n.times{
res=[0,0,0]
k,name=gets.split
k.to_i.times{
a1,a2,a3=gets.split[0].split('-')
t=a1+a2+a3
if taxi.include?(t)
res[0]+=1
else
v=Array.new(6){0}
6.times{|i| v[i]=t[i].to_i }
ok=true
5.times{|i|
ok=false if v[i]<=v[i+1]
}
if ok
res[1]+=1
else
res[2]+=1
end
end
}
3.times{|i|
max[i]=[max[i],res[i]].max
}
shop.push([name,res])
}
output=["If you want to call a taxi, you should call: ", "If you want to order a pizza, you should call: ","If you want to go to a cafe with a wonderful girl, you should call: "]
3.times{|k|
print output[k]
start=true
shop.each{|t|
if (t[1][k]==max[k]) then
print ", " unless start
start=false
print t[0]
end
}
puts "."
}