This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = gets.chomp | |
puts n[0..-5] + "2015" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
n = gets.chomp.to_i | |
c = gets.chomp.split("").map(&:to_i) | |
ans = [1,2,3,4] | |
cnt = [] | |
ans.each do |a| | |
cnt << c.count(a) | |
end | |
print cnt.max, " ", cnt.min, "\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LiveConcert(): | |
def maxHappiness(self, h, s): | |
dict = {} | |
m = len(h) | |
for (key, val) in zip(s, h): | |
if dict.has_key(key): | |
dict[key].append(val) | |
else: | |
dict[key] = [val] | |
happiness = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = gets.chomp.split(" ") | |
res = [] | |
s.each do |i| | |
case i | |
when "Left" then res << "<" | |
when "Right" then res << ">" | |
when "AtCoder" then res << "A" | |
end | |
end | |
puts res.join(" ") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Cdgame(): | |
def rescount(self, a, b): | |
sum_a = sum(a) | |
sum_b = sum(b) | |
res = [] | |
for i in a: | |
for j in b: | |
res.append((sum_a-i+j)*(sum_b-j+i)) | |
return(len(set(res))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ALDS1_1_D Maximum Profit | |
n = gets.chomp.to_i | |
r = [] | |
n.times do | |
r << gets.chomp.to_i | |
end | |
maxv = r[1] - r[0] | |
minv = r[0] | |
(1..n-1).each do |i| | |
maxv = [maxv, r[i] - minv].max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ALDS1_1_A Insertion Sort | |
n = gets.chomp.to_i | |
a = gets.chomp.split(" ").map(&:to_i) | |
def insertionSort(a, n) | |
puts a.join(" ") | |
(1..n-1).each do |i| | |
v = a[i] | |
j = i - 1 | |
while j >= 0 and a[j] > v | |
a[j+1] = a[j] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# #325 Div2 A. Alena's Schedule | |
n = gets.chomp.to_i | |
a = gets.chomp.split(" ").map(&:to_i) | |
lesson = 0 | |
rest = 0 | |
a.each do |i| | |
if i == 1 then | |
if rest == 1 and lesson > 0 then | |
lesson += 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SRM #645 Div2 Easy | |
class BacteriesColony(): | |
def performTheExperiment(self, c): | |
while True: | |
diff = [0] * len(c) | |
for i in range(1, len(c)-1): | |
if c[i] > c[i-1] and c[i] > c[i+1]: | |
diff[i] = -1 | |
elif c[i] < c[i-1] and c[i] < c[i+1]: | |
diff[i] = 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# SRM 646 Div2 Easy | |
class TheConsecutiveIntegersDivTwo(): | |
def find(self, numbers, k): | |
if k == 1: | |
return 0 | |
else: | |
n_sorted = sorted(numbers) | |
n_diff = [n_sorted[i+1] - n_sorted[i] for i in range(len(numbers)-1)] | |
return min(n_diff) - 1 |