結果

問題 No.973 余興
ユーザー SugihaMSugihaM
提出日時 2020-04-22 17:52:12
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,716 bytes
コンパイル時間 10,409 ms
コンパイル使用メモリ 235,176 KB
実行使用メモリ 222,248 KB
最終ジャッジ日時 2024-04-20 03:03:00
合計ジャッジ時間 41,013 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 800 ms
220,288 KB
testcase_01 AC 788 ms
220,288 KB
testcase_02 AC 778 ms
220,160 KB
testcase_03 AC 782 ms
220,032 KB
testcase_04 AC 785 ms
220,288 KB
testcase_05 WA -
testcase_06 AC 790 ms
220,160 KB
testcase_07 AC 798 ms
220,032 KB
testcase_08 AC 789 ms
219,392 KB
testcase_09 AC 778 ms
220,288 KB
testcase_10 AC 736 ms
212,224 KB
testcase_11 WA -
testcase_12 AC 314 ms
86,016 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 26 ms
14,208 KB
testcase_16 AC 29 ms
14,336 KB
testcase_17 AC 17 ms
11,008 KB
testcase_18 AC 24 ms
12,544 KB
testcase_19 AC 23 ms
12,544 KB
testcase_20 WA -
testcase_21 AC 28 ms
14,208 KB
testcase_22 AC 27 ms
14,208 KB
testcase_23 AC 21 ms
12,544 KB
testcase_24 WA -
testcase_25 AC 6 ms
7,424 KB
testcase_26 AC 14 ms
10,880 KB
testcase_27 WA -
testcase_28 AC 20 ms
12,544 KB
testcase_29 AC 21 ms
12,288 KB
testcase_30 AC 915 ms
220,288 KB
testcase_31 AC 936 ms
220,288 KB
testcase_32 AC 946 ms
220,288 KB
testcase_33 AC 944 ms
220,032 KB
testcase_34 AC 931 ms
219,392 KB
testcase_35 AC 926 ms
220,288 KB
testcase_36 WA -
testcase_37 AC 912 ms
214,912 KB
testcase_38 AC 922 ms
219,648 KB
testcase_39 AC 907 ms
219,904 KB
testcase_40 AC 1 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 945 ms
220,288 KB
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 875 ms
204,160 KB
testcase_50 AC 953 ms
218,752 KB
testcase_51 AC 954 ms
220,288 KB
testcase_52 AC 892 ms
220,288 KB
testcase_53 AC 876 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 := 1; 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