코딩도장

코딩도장

변경이력

돌아가기
2 35개 문자 삭제

2023年06月27日 11:07

insperChoi

```{.python} global chosen global chosen_size chosen = [] chosen_size = 0 def near_cartsize(idx, s, things, cartsize, curr): global chosen global chosen_size if idx >= len(things): if chosen_size < s: chosen = curr.copy() chosen_size = s return for j in range(idx, len(things)): if s + things[j] <= cartsize: curr.append(things[j]) s += things[j] near_cartsize(j+1, s, things, cartsize, curr) curr.remove(things[j]) s -= things[j] else: if chosen_size < s: chosen = curr.copy() chosen_size = s def choose(things, cartsize): global chosen global chosen_size chosen = [] chosen_size = 0 things.sort(reverse=True) near_cartsize(1, things[0], things, cartsize, [things[0]], ) return chosen 총 이동: 42665 ```
```{.python} global chosen global chosen_size chosen = [] chosen_size = 0 def near_cartsize(idx, s, things, cartsize, curr): global chosen global chosen_size if idx >= len(things): if chosen_size < s: chosen = curr.copy() chosen_size = s return for j in range(idx, len(things)): if s + things[j] <= cartsize: curr.append(things[j]) s += things[j] near_cartsize(j+1, s, things, cartsize, curr) curr.remove(things[j]) s -= things[j] else: if chosen_size < s: chosen = curr.copy() chosen_size = s def choose(things, cartsize): global chosen global chosen_size chosen = [] chosen_size = 0 things.sort(reverse=True) near_cartsize(1, things[0], things, cartsize, [things[0]], ) return chosen 총 이동: 42665 ```
```{.python} global chosen global chosen_size chosen = [] chosen_size = 0 def near_cartsize(idx, s, things, cartsize, curr): global chosen global chosen_size if idx >= len(things): if chosen_size < s: chosen = curr.copy() chosen_size = s return for j in range(idx, len(things)): if s + things[j] <= cartsize: curr.append(things[j]) s += things[j] near_cartsize(j+1, s, things, cartsize, curr) curr.remove(things[j]) s -= things[j] else: if chosen_size < s: chosen = curr.copy() chosen_size = s def choose(things, cartsize): global chosen global chosen_size chosen = [] chosen_size = 0 things.sort(reverse=True) near_cartsize(1, things[0], things, cartsize, [things[0]], ) return chosen 총 이동: 42665 ```
1 Original

2023年06月27日 10:37

insperChoi

```{.python} global chosen global chosen_size chosen = [] chosen_size = 0 def near_cartsize(idx, s, things, cartsize, curr): global chosen global chosen_size if idx >= len(things): if chosen_size < s: chosen = curr.copy() chosen_size = s return for j in range(idx, len(things)): if s + things[j] <= cartsize: curr.append(things[j]) s += things[j] near_cartsize(j+1, s, things, cartsize, curr) curr.remove(things[j]) s -= things[j] else: if chosen_size < s: chosen = curr.copy() chosen_size = s def choose(things, cartsize): global chosen global chosen_size chosen = [] chosen_size = 0 things.sort(reverse=True) near_cartsize(1, things[0], things, cartsize, [things[0]], ) return chosen 총 이동: 42665 ```
```{.python} global chosen global chosen_size chosen = [] chosen_size = 0 def near_cartsize(idx, s, things, cartsize, curr): global chosen global chosen_size if idx >= len(things): if chosen_size < s: chosen = curr.copy() chosen_size = s return for j in range(idx, len(things)): if s + things[j] <= cartsize: curr.append(things[j]) s += things[j] near_cartsize(j+1, s, things, cartsize, curr) curr.remove(things[j]) s -= things[j] else: if chosen_size < s: chosen = curr.copy() chosen_size = s def choose(things, cartsize): global chosen global chosen_size chosen = [] chosen_size = 0 things.sort(reverse=True) near_cartsize(1, things[0], things, cartsize, [things[0]], ) return chosen 총 이동: 42665 ```
코딩도장

코딩도장은 프로그래밍 문제풀이를 통해서 코딩 실력을 수련(Practice)하는 곳입니다.

코딩도장 © 2014 · 문의 [email protected]
피드백 · 개인정보취급방침 · RSS

AltStyle によって変換されたページ (->オリジナル) /