結果

問題 No.973 余興
ユーザー SugihaMSugihaM
提出日時 2020-04-22 17:23:52
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,734 bytes
コンパイル時間 12,238 ms
コンパイル使用メモリ 224,124 KB
実行使用メモリ 368,736 KB
最終ジャッジ日時 2024-04-20 02:08:23
合計ジャッジ時間 36,961 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 715 ms
276,956 KB
testcase_01 AC 707 ms
276,960 KB
testcase_02 AC 709 ms
276,828 KB
testcase_03 AC 711 ms
278,616 KB
testcase_04 AC 708 ms
277,468 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 660 ms
270,640 KB
testcase_11 AC 217 ms
168,308 KB
testcase_12 AC 221 ms
167,996 KB
testcase_13 WA -
testcase_14 AC 205 ms
166,384 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 24 ms
67,660 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 34 ms
84,132 KB
testcase_23 AC 30 ms
74,052 KB
testcase_24 AC 28 ms
75,892 KB
testcase_25 AC 18 ms
51,128 KB
testcase_26 AC 24 ms
65,608 KB
testcase_27 AC 35 ms
90,308 KB
testcase_28 WA -
testcase_29 AC 27 ms
75,892 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 660 ms
277,848 KB
testcase_35 AC 653 ms
277,468 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 663 ms
278,104 KB
testcase_39 WA -
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 1 ms
6,944 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 WA -
testcase_44 AC 1 ms
6,944 KB
testcase_45 WA -
testcase_46 AC 681 ms
277,472 KB
testcase_47 WA -
testcase_48 AC 656 ms
277,464 KB
testcase_49 WA -
testcase_50 AC 651 ms
277,204 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 690 ms
274,512 KB
testcase_54 AC 696 ms
277,464 KB
testcase_55 AC 694 ms
277,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}
func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 100000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	x, _ := strconv.Atoi(Scanner())
	a := make([]int, 5000)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(Scanner())
	}

	l := make([]int, 5000)
	r := make([]int, 5000)
	sum := 0
	b := 0
	c := 0

	for b != n {
		for c != n && sum+a[c] <= x {
			sum += a[c]
			c++
		}
		l[b] = c - b
		sum -= a[b]
		b++
	}
	b = n - 1
	c = n - 1
	sum = 0
	for c >= 0 {
		for b != 0 && sum+a[b] <= x {
			sum += a[b]
			b--
		}
		r[c] = c - b
		sum -= a[c]
		c--
	}

	dp_l := make([][]int, 5000)
	for i := 0; i < n; i++ {
		dp_l[i] = make([]int, 5001)
	}
	dp_r := make([][]int, 5000)
	for i := 0; i < n; i++ {
		dp_r[i] = make([]int, 5001)
	}
	left := 0
	right := 0
	q := 0
	for i := 0; i <= n; i++ {
		for j := 0; j < n; j++ {
			if i == 0 {
				dp_l[j][i] = 0
				dp_r[j][i] = 0
				continue
			}
			left = j
			right = j + i - 1
			if right >= n {
				break
			}
			q = min(l[left], i-1)
			p := dp_r[right][i-1] - dp_r[right][i-q-1]
			if p != q {
				dp_l[left][i] = dp_l[left][i-1] + 1
				dp_r[right][i] = dp_r[right][i-1] + 1
				continue
			}

			q = min(r[right], i-1)
			p = dp_l[left][i-1] - dp_l[left][i-q-1]
			if p != q {
				dp_l[left][i] = dp_l[left][i-1] + 1
				dp_r[right][i] = dp_r[right][i-1] + 1
				continue
			}
			dp_l[left][i] = dp_l[left][i-1]
			dp_r[right][i] = dp_r[right][i-1]
		}
	}
	ans := "A"
	if dp_l[0][n] == dp_r[0][n-1] {
		ans = "B"
	}
	fmt.Println(ans)
}

func min(x int, y int) int {
	if x >= y {
		return y
	} else {
		return x
	}
}
0