This repository was archived by the owner on Sep 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 164
/
Copy pathcapacity-to-ship-packages-within-d-days_test.go
executable file
·75 lines (61 loc) · 3.21 KB
/
capacity-to-ship-packages-within-d-days_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package problem1011
import (
"testing"
"github.com/stretchr/testify/assert"
)
// tcs is testcase slice
var tcs = []struct {
weights []int
D int
ans int
}{
{
[]int{59, 468, 1, 380, 122, 368, 175, 383, 398, 422, 175, 403, 11, 415, 62, 379, 418, 406, 485, 410, 440, 364, 329, 8, 235, 461, 308, 69, 347, 37, 450, 187, 382, 44, 209, 463, 393, 478, 162, 376, 88, 335, 70, 3, 233, 375, 54, 412, 270, 299, 155, 243, 195, 423, 402, 464, 6, 63, 473, 149, 62, 162, 320, 490, 27, 30, 226, 488, 451, 18, 85, 179, 303, 425, 333, 210, 128, 422, 334, 475, 387, 379, 81, 196, 310, 48, 16, 171, 472, 35, 103, 434, 61, 498, 195, 168, 167, 394, 254, 99, 190, 316, 393, 40, 397, 170, 437, 442, 291, 323, 415, 336, 143, 400, 352, 42, 201, 28, 233, 43, 142, 81, 24, 378, 384, 156, 250, 376, 172, 493, 179, 500, 89, 104, 69, 320, 108, 238, 89, 245, 478, 242, 344, 47, 112, 188, 383, 10, 488, 9, 471, 430, 129, 1, 154, 344, 235, 456, 29, 115, 9, 394, 192, 12, 349, 415, 101, 398, 383, 175, 465, 267, 206, 71, 113, 448, 205, 202, 254, 221, 336, 425, 470, 455, 344, 172, 425, 417, 291, 190, 24, 240, 14, 397, 61, 246, 128, 232, 189, 210, 186, 163, 33, 386, 258, 50, 326, 412, 134, 19, 141, 158, 459, 403, 124, 99, 344, 269, 383, 151, 419, 495, 44, 295, 331, 59, 71, 386, 408, 79, 214, 217, 425, 189, 134, 232, 294, 232, 444, 198, 488, 21, 457, 118, 471, 256, 95, 428, 447, 112, 238, 408, 391, 270, 335, 244, 13, 402, 69, 121, 357, 221, 463, 113, 329, 193, 483, 384, 182, 380, 178, 263, 458, 422, 265, 439, 252, 222, 138, 88, 47, 465, 117, 91, 291, 107, 391, 239, 19, 108, 443, 497, 357, 432, 12, 252, 457, 96, 264, 210, 118, 395, 116, 445, 60, 361, 193, 363, 448, 435, 245, 190, 263, 169, 376, 381, 168, 403, 196, 477, 281, 16, 33, 84, 138, 10, 213, 434, 373, 464, 413, 351, 167, 411, 54, 134, 90, 102, 46, 41, 25, 270, 252, 383, 380, 499, 3, 128, 17, 392, 144, 433, 447, 383, 219, 262, 363, 82, 463, 461, 214, 207, 255, 398, 104, 306, 469, 385, 36, 202, 490, 350, 370, 207, 156, 153, 396, 155, 219, 298, 430, 480, 1, 415, 278, 55, 418, 353, 60, 169, 164, 43, 91, 489, 1, 7, 309, 159, 208, 246, 283, 140, 247, 204, 387, 15, 412, 182, 409, 61, 431, 394, 147, 150, 62, 423, 165, 298, 333, 467, 293, 226, 291, 187, 188, 368, 483, 234, 459, 386, 103, 374, 302, 320, 492, 277, 25, 21, 36, 149, 178, 78, 359, 457, 101, 139, 491, 266, 64, 352, 353, 471, 55, 265, 105, 101, 281, 286, 5, 27, 165, 360, 114, 344, 262, 266, 290, 464, 451, 209, 265, 371, 59, 453, 224, 465, 463, 261, 1, 295, 475, 71, 308, 1, 53, 58, 355, 470, 222, 242, 364, 275, 223, 484, 294, 8, 125, 75, 155, 469, 141, 319, 377, 258, 161, 374, 89, 52, 165, 206, 366, 6},
256,
682,
},
{
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
10,
10,
},
{
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
1,
55,
},
{
[]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10},
5,
15,
},
{
[]int{1, 2, 3, 1, 1},
4,
3,
},
{
[]int{1, 1, 1},
3,
1,
},
{
[]int{3, 2, 2, 4, 1, 4},
3,
6,
},
// 可以有多个 testcase
}
func Test_shipWithinDays(t *testing.T) {
ast := assert.New(t)
for _, tc := range tcs {
ast.Equal(tc.ans, shipWithinDays(tc.weights, tc.D), "输入:%v", tc)
}
}
func Benchmark_shipWithinDays(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, tc := range tcs {
shipWithinDays(tc.weights, tc.D)
}
}
}