結果

問題 No.973 余興
ユーザー SugihaMSugihaM
提出日時 2020-04-22 17:05:01
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,739 bytes
コンパイル時間 11,060 ms
コンパイル使用メモリ 237,664 KB
実行使用メモリ 405,348 KB
最終ジャッジ日時 2024-04-20 01:43:37
合計ジャッジ時間 36,302 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 691 ms
306,776 KB
testcase_01 AC 673 ms
306,776 KB
testcase_02 AC 691 ms
307,548 KB
testcase_03 AC 697 ms
308,444 KB
testcase_04 AC 694 ms
307,672 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 648 ms
301,360 KB
testcase_11 AC 244 ms
148,380 KB
testcase_12 AC 238 ms
148,388 KB
testcase_13 WA -
testcase_14 AC 232 ms
148,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 12 ms
13,852 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 22 ms
19,328 KB
testcase_23 AC 18 ms
18,228 KB
testcase_24 AC 16 ms
18,216 KB
testcase_25 AC 7 ms
9,720 KB
testcase_26 AC 11 ms
13,848 KB
testcase_27 AC 20 ms
24,280 KB
testcase_28 WA -
testcase_29 AC 15 ms
18,212 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 730 ms
307,796 KB
testcase_35 AC 740 ms
307,676 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 746 ms
308,064 KB
testcase_39 WA -
testcase_40 AC 1 ms
6,940 KB
testcase_41 AC 1 ms
6,944 KB
testcase_42 AC 1 ms
6,944 KB
testcase_43 WA -
testcase_44 AC 1 ms
6,944 KB
testcase_45 WA -
testcase_46 AC 753 ms
307,676 KB
testcase_47 WA -
testcase_48 AC 748 ms
302,048 KB
testcase_49 WA -
testcase_50 AC 726 ms
301,652 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 729 ms
299,344 KB
testcase_54 AC 747 ms
302,048 KB
testcase_55 AC 751 ms
302,040 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, n)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(Scanner())
	}

	l := make([]int, n)
	r := make([]int, n)
	sum := 0
	count := 0
	for i := 0; i < n; i++ {
		for j := i; j < n; j++ {
			sum += a[j]
			if sum > x {
				break
			}
			count++
		}
		l[i] = count
		sum = 0
		count = 0
		for j := i; j < n; j++ {
			sum += a[j]
			if sum > x {
				break
			}
			count++
		}
		r[i] = count
	}

	dp_l := make([][]int, n+1)
	for i := 0; i < n; i++ {
		dp_l[i] = make([]int, n+1)
	}
	dp_r := make([][]int, n+1)
	for i := 0; i < n; i++ {
		dp_r[i] = make([]int, n+1)
	}
	left := 0
	right := 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
			}
			count = min(l[left], i-1)
			p := dp_r[right][i-1] - dp_r[right][i-count-1]
			if p != count {
				dp_l[left][i] = dp_l[left][i-1] + 1
				dp_r[right][i] = dp_r[right][i-1] + 1
				continue
			}

			count = min(r[right], i-1)
			p = dp_l[left][i-1] - dp_l[left][i-count-1]
			if p != count {
				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