mirror of
https://github.com/krahets/hello-algo.git
synced 2026-07-21 02:56:11 +00:00
772183705e
* Add Russian docs site baseline * Add Russian localized codebase * Polish Russian code wording * Update ru code translation. * Update code translation and chapter covers. * Fix pythontutor extraction. * Add README and landing page. * placeholder of profiles * Use figures of English version * Remove chapter paperbook
21 lines
525 B
Go
21 lines
525 B
Go
// File: fractional_knapsack_test.go
|
|
// Created Time: 2023-07-23
|
|
// Author: Reanon (793584285@qq.com)
|
|
|
|
package chapter_greedy
|
|
|
|
import (
|
|
"fmt"
|
|
"testing"
|
|
)
|
|
|
|
func TestFractionalKnapsack(t *testing.T) {
|
|
wgt := []int{10, 20, 30, 40, 50}
|
|
val := []int{50, 120, 150, 210, 240}
|
|
capacity := 50
|
|
|
|
// Жадный алгоритм
|
|
res := fractionalKnapsack(wgt, val, capacity)
|
|
fmt.Println("Максимальная стоимость предметов без превышения вместимости рюкзака =", res)
|
|
}
|