This file contains hidden or 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
# ไบๅๆจๆข็ดข Binary Search Tree | |
class Node | |
attr_accessor :val, :left, :right | |
def initialize(val) | |
@val = val | |
end | |
end | |
def insert(node, val) |
This file contains hidden or 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
$heap = [] | |
$size = 0 | |
# heapๅฎ่ฃ | |
def push(x) | |
# ใใผใใ็ฉบใชใRootใซ่ฟฝๅ ใใฆๆใใ | |
return $heap[0] = x if $heap.empty? | |
# ่ฟฝๅ ใใใใใผใใๅใพใindex | |
i = $size += 1 |
This file contains hidden or 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
# input | |
$n = 4 | |
$m = 4 | |
$s = "abcd" | |
$t = "becd" | |
# 2ใคใฎๆๅญๅใฎใๅ ฑ้้จๅๅใฎ้ทใใฎๆๅคงๅคใๆฑใใ | |
# ่งฃ 3 "bcd" | |
$dp = Array.new($n + 1, 0){ Array.new($m + 1, 0)} |
This file contains hidden or 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
# input | |
$n = 4 | |
$w = [2, 1, 3, 2] | |
$v = [3, 2, 4, 2] | |
$W = 5 | |
$dp = Array.new($n + 1, 0){ Array.new($W + 1, 0)} | |
# ้ใ$wใจไพกๅค$vใฎ็ตใฟๅใใใฎๅ็ฉใ$nๅใใ | |
# ้ใใฎ็ทๅใ$Wใ่ถ ใใชใใใใซ้ธใใ ใจใใฎไพกๅคใฎ็ทๅใฎๆๅคงๅคใๆฑใใ | |
# ๅ็่จ็ปๆณ Dynamic Programming |
This file contains hidden or 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
# input | |
$n = 4 | |
$w = [2, 1, 3, 2] | |
$v = [3, 2, 4, 2] | |
$W = 5 | |
$dp = Array.new($n + 1, -1){ Array.new($W + 1, -1)} | |
# ้ใ$wใจไพกๅค$vใฎ็ตใฟๅใใใฎๅ็ฉใ$nๅใใ | |
# ้ใใฎ็ทๅใ$Wใ่ถ ใใชใใใใซ้ธใใ ใจใใฎไพกๅคใฎ็ทๅใฎๆๅคงๅคใๆฑใใ |
This file contains hidden or 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
# input | |
$n = 4 | |
$w = [2, 1, 3, 2] | |
$v = [3, 2, 4, 2] | |
$W = 5 | |
# ้ใ$wใจไพกๅค$vใฎ็ตใฟๅใใใฎๅ็ฉใ$nๅใใ | |
# ้ใใฎ็ทๅใ$Wใ่ถ ใใชใใใใซ้ธใใ ใจใใฎไพกๅคใฎ็ทๅใฎๆๅคงๅคใๆฑใใ | |
def rec(i, j) |
This file contains hidden or 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
#input | |
$V = [1, 5, 10, 50, 100, 500] | |
# 1ๅ็3ๆ, 10ๅ็2ๆ... 500ๅ็2ๆ | |
$C = [3, 2, 1, 3, 0, 2] | |
$A = 620 #620ๅๆฏๆใ | |
# $Aๅใๆฏๆใๆๅฐใฎ็กฌ่ฒจๆฐใๆฑใใ | |
def slove |
This file contains hidden or 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
# input | |
MAX_N, MAX_M = 100, 100 | |
$INF = 100_000_000 | |
str = <<"EOS" | |
#S.#.....# | |
#.....##.# | |
#.#.#..#..# | |
#..#..#### | |
####G##### |
This file contains hidden or 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
# input | |
$n = 4 | |
$a = [1, 2, 4, 7] | |
$k = 13 | |
# ้ ๅaใใใใใคใ้ธใณใใใฎๅใใกใใใฉkใซใใใใจใ | |
# ใงใใใใๆฑใใ | |
def dfs(i, sum) | |
return sum == $k if i == $n |
This file contains hidden or 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
let scrollstep = 250 | |
let blacklists = ["*://gist.github.com/*", "*://github.com/*", "*://mail.google.com/*", "*://*.rakuten-bank.co.jp/*"] |