Skip to content

Instantly share code, notes, and snippets.

@whatalnk
whatalnk / srm647_div2_easy_PeacefulLine.py
Created October 13, 2015 11:58
TopCoder SRM 647 Div2
# SRM 647 Div2 Easy
# http://community.topcoder.com/stat?c=problem_statement&pm=13632
class PeacefulLine():
def makeLine(self, x):
d = {}
for i in x:
if i in d.keys():
d[i] += 1
else:
@whatalnk
whatalnk / srm648_div2_easy_KitayutaMart2.py
Created October 14, 2015 04:09
TopCoder SRM 648 Div2
# SRM 648 Div2 Easy
#http://community.topcoder.com/stat?c=problem_statement&pm=13650
class KitayutaMart2():
def numBought(self, k, t):
n = 1
ksum = k
while True:
if ksum == t:
return n
n += 1
@whatalnk
whatalnk / srm671_div2_easy_BearPaints.py
Last active October 20, 2015 11:47
TopCoder SRM 671 Div2
# SRM 671 Div2 Easy
# [Very short Editorial of SRM #671 - Codeforces](http://codeforces.com/blog/entry/20939)
class BearPaints():
def maxArea(self, w, h, m):
area = 1
for i in range(1,w+1):
area = max(area, i * min(m/i, h))
return area
@whatalnk
whatalnk / srm672_div2_a_SetPartialOrder.py
Last active October 22, 2015 05:45
TopCoder SRM672 Div2
# SRM 672 Div2 Easy
class SetPartialOrder():
def compareSets(self, a, b):
seta = set(a)
setb = set(b)
if seta == setb:
return "EQUAL"
elif seta.issubset(setb):
return "LESS"
elif setb.issubset(seta):
@whatalnk
whatalnk / no005.rb
Last active December 26, 2015 12:48
yukicoderメモ
l = gets.chomp.to_i
n = gets.chomp.to_i
w = gets.chomp.split(" ").map(&:to_i)
w.sort!
ww = 0
i = 0
w.each do |a|
ww += a
if ww > l then
break
@whatalnk
whatalnk / cf328_div2_a_PawnChess.rb
Last active November 5, 2015 16:38
Codeforces #328 Div2
# [Problem - 592A - Codeforces](http://codeforces.com/problemset/problem/592/A)
field = []
while line = gets
field << line.chomp.split("")
end
field = field.transpose
stepA = []
stepB = []
field.each do |r|
a = r.rindex("W")
@whatalnk
whatalnk / cf329-div2-a-2Char.rb
Last active November 5, 2015 16:39
Codeforces #329 Div2
# [Problem - A - Codeforces](http://codeforces.com/contest/593/problem/A)
n = gets.chomp.to_i
d = Hash.new(0)
n.times do
word = gets.chomp
k = word.split("").uniq.sort
v = word.length
d[k] += v if k.length <= 2
end
res = 0
@whatalnk
whatalnk / CodeFes20115-QualB-a-DoubleString.rb.rb
Last active November 7, 2015 17:19
Code Festival 2015 予選 B
# [A: ダブル文字列/Double String - CODE FESTIVAL 2015 予選B | AtCoder](http://code-festival-2015-qualb.contest.atcoder.jp/tasks/codefestival_2015_qualB_a)
s = gets.chomp
puts s.split("").uniq.join("")*2
@whatalnk
whatalnk / getExampleCases.user.js
Last active November 9, 2015 02:27
AtCoderの入出力を取得
// ==UserScript==
// @name getExampleCases
// @namespace what_alnk
// @description AtCoderの入力例と出力例をコピーするボタンを設置する
// @include /^http://[0-9a-zA-Z]+\.contest\.atcoder\.jp/tasks/[A-D]/
// @version 1.2
// @grant none
// ==/UserScript==
// 通知許可確認
@whatalnk
whatalnk / getExampleCasesInCodeforces.user.js
Last active March 2, 2016 10:03
Codeforcesの入力例と出力例をコピーするボタンを設置する
// ==UserScript==
// @name getExampleCasesInCodeforces
// @namespace what_alnk
// @description Codeforcesの入力例と出力例をコピーするボタンを設置する
// @include /^http://codeforces\.com/contest/\d{3}/problem/[0-9A-E]$/
// @version 1.2.1
// @grant none
// ==/UserScript==
// 通知