結果

問題 No.973 余興
ユーザー SugihaMSugihaM
提出日時 2020-04-22 17:55:21
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,716 bytes
コンパイル時間 12,267 ms
コンパイル使用メモリ 222,776 KB
実行使用メモリ 220,288 KB
最終ジャッジ日時 2024-04-20 03:07:06
合計ジャッジ時間 42,967 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 774 ms
220,288 KB
testcase_01 AC 803 ms
220,288 KB
testcase_02 AC 800 ms
220,160 KB
testcase_03 AC 817 ms
220,032 KB
testcase_04 AC 811 ms
220,288 KB
testcase_05 WA -
testcase_06 AC 823 ms
220,160 KB
testcase_07 AC 818 ms
220,032 KB
testcase_08 AC 822 ms
219,392 KB
testcase_09 AC 814 ms
220,288 KB
testcase_10 AC 751 ms
212,224 KB
testcase_11 WA -
testcase_12 AC 282 ms
86,016 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 27 ms
14,208 KB
testcase_16 AC 25 ms
14,464 KB
testcase_17 AC 12 ms
11,008 KB
testcase_18 AC 19 ms
12,544 KB
testcase_19 AC 20 ms
12,544 KB
testcase_20 WA -
testcase_21 AC 24 ms
14,208 KB
testcase_22 AC 24 ms
14,208 KB
testcase_23 AC 18 ms
12,544 KB
testcase_24 WA -
testcase_25 AC 7 ms
7,424 KB
testcase_26 AC 17 ms
10,752 KB
testcase_27 WA -
testcase_28 AC 14 ms
12,544 KB
testcase_29 AC 15 ms
12,288 KB
testcase_30 AC 937 ms
220,288 KB
testcase_31 AC 932 ms
220,288 KB
testcase_32 AC 932 ms
220,288 KB
testcase_33 AC 928 ms
220,032 KB
testcase_34 AC 920 ms
219,392 KB
testcase_35 AC 981 ms
220,288 KB
testcase_36 WA -
testcase_37 AC 919 ms
214,912 KB
testcase_38 AC 934 ms
219,648 KB
testcase_39 AC 894 ms
219,904 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 AC 1 ms
5,376 KB
testcase_42 AC 1 ms
5,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 1 ms
5,376 KB
testcase_46 AC 942 ms
220,288 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 861 ms
204,160 KB
testcase_50 AC 932 ms
218,752 KB
testcase_51 AC 938 ms
220,288 KB
testcase_52 AC 925 ms
220,288 KB
testcase_53 AC 870 ms
216,704 KB
testcase_54 WA -
testcase_55 WA -
権限があれば一括ダウンロードができます

ソースコード

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 >= 0; 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)
			if dp_r[right][i-1]-dp_r[right][i-count-1] != 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)
			if dp_l[left][i-1]-dp_l[left][i-count-1] != 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_l[0][n-1] {
		ans = "B"
	}
	fmt.Println(ans)
}

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