結果
問題 | No.1701 half price |
ユーザー | 小野寺健 |
提出日時 | 2021-12-20 13:03:51 |
言語 | Go (1.21.3) |
結果 |
AC
|
実行時間 | 618 ms / 3,000 ms |
コード長 | 938 bytes |
コンパイル時間 | 10,797 ms |
コンパイル使用メモリ | 213,856 KB |
実行使用メモリ | 148,608 KB |
最終ジャッジ日時 | 2023-10-13 19:31:02 |
合計ジャッジ時間 | 12,814 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,356 KB |
testcase_01 | AC | 1 ms
4,352 KB |
testcase_02 | AC | 1 ms
4,352 KB |
testcase_03 | AC | 1 ms
4,348 KB |
testcase_04 | AC | 2 ms
4,352 KB |
testcase_05 | AC | 2 ms
4,348 KB |
testcase_06 | AC | 1 ms
4,352 KB |
testcase_07 | AC | 2 ms
4,352 KB |
testcase_08 | AC | 1 ms
4,352 KB |
testcase_09 | AC | 2 ms
4,352 KB |
testcase_10 | AC | 2 ms
4,348 KB |
testcase_11 | AC | 1 ms
4,348 KB |
testcase_12 | AC | 1 ms
4,348 KB |
testcase_13 | AC | 1 ms
4,348 KB |
testcase_14 | AC | 1 ms
4,352 KB |
testcase_15 | AC | 1 ms
4,348 KB |
testcase_16 | AC | 1 ms
4,352 KB |
testcase_17 | AC | 235 ms
50,840 KB |
testcase_18 | AC | 2 ms
4,348 KB |
testcase_19 | AC | 2 ms
4,348 KB |
testcase_20 | AC | 2 ms
4,352 KB |
testcase_21 | AC | 618 ms
148,608 KB |
ソースコード
package main import ( "fmt" "bufio" "os" "strconv" ) type Cell struct { n int s string } func newCell(n int, s string) *Cell { cp := new(Cell) cp.n = n cp.s = s return cp } func main() { r := bufio.NewReader(os.Stdin) w := bufio.NewWriter(os.Stdout) defer w.Flush() var N, W int fmt.Fscan(r, &N, &W) a := make([]int, N) for i := 0; i < N; i++ { fmt.Fscan(r, &a[i]) } w0 := make([]*Cell, 1) w0[0] = newCell(0, "") for i := 0; i < N; i++ { w1 := make([]*Cell, 0) for _, wv := range w0 { w, v := wv.n, wv.s w1 = append(w1, newCell(w, v)) if w + a[i] / 2 <= W { w1 = append(w1, newCell(w + a[i] / 2, v + strconv.Itoa(i) + ",")) } if w + a[i] <= W { w1 = append(w1, newCell(w + a[i], v + strconv.Itoa(i) + ",")) } } w0 = w1 } if W == 0 { w0 = w0[1:] } m := make(map[string]bool) for _, xy := range w0 { if xy.n == W { m[xy.s] = true } } fmt.Fprintln(w, len(m)) }