結果

問題 No.973 余興
ユーザー SugihaMSugihaM
提出日時 2020-04-22 17:33:26
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,707 bytes
コンパイル時間 12,170 ms
コンパイル使用メモリ 225,492 KB
実行使用メモリ 325,468 KB
最終ジャッジ日時 2024-04-20 02:28:18
合計ジャッジ時間 39,193 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 725 ms
220,160 KB
testcase_03 AC 702 ms
220,032 KB
testcase_04 AC 717 ms
220,288 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 713 ms
219,392 KB
testcase_09 AC 707 ms
220,288 KB
testcase_10 AC 689 ms
212,224 KB
testcase_11 AC 250 ms
86,016 KB
testcase_12 AC 256 ms
86,016 KB
testcase_13 AC 233 ms
85,376 KB
testcase_14 WA -
testcase_15 AC 24 ms
14,208 KB
testcase_16 AC 20 ms
14,464 KB
testcase_17 AC 12 ms
10,880 KB
testcase_18 AC 18 ms
12,544 KB
testcase_19 WA -
testcase_20 AC 12 ms
10,752 KB
testcase_21 AC 23 ms
14,208 KB
testcase_22 AC 23 ms
14,208 KB
testcase_23 AC 17 ms
12,544 KB
testcase_24 AC 16 ms
12,416 KB
testcase_25 AC 6 ms
7,424 KB
testcase_26 AC 11 ms
10,752 KB
testcase_27 AC 21 ms
18,304 KB
testcase_28 AC 17 ms
12,544 KB
testcase_29 AC 16 ms
12,288 KB
testcase_30 AC 793 ms
220,288 KB
testcase_31 AC 786 ms
220,288 KB
testcase_32 AC 778 ms
220,288 KB
testcase_33 AC 798 ms
220,032 KB
testcase_34 AC 784 ms
219,392 KB
testcase_35 AC 783 ms
220,288 KB
testcase_36 AC 770 ms
214,912 KB
testcase_37 WA -
testcase_38 AC 796 ms
219,648 KB
testcase_39 AC 777 ms
219,904 KB
testcase_40 AC 1 ms
5,376 KB
testcase_41 AC 2 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 793 ms
220,288 KB
testcase_47 WA -
testcase_48 AC 797 ms
220,288 KB
testcase_49 AC 725 ms
204,160 KB
testcase_50 AC 794 ms
218,752 KB
testcase_51 AC 804 ms
220,288 KB
testcase_52 AC 793 ms
220,288 KB
testcase_53 AC 873 ms
216,704 KB
testcase_54 AC 796 ms
220,288 KB
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 < 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)
	}
	for i := 0; i < n; i++ {
		dp_l[i][0] = 0
		dp_r[i][0] = 0
	}
	left := 0
	right := 0
	for i := 1; i <= n; i++ {
		for j := 0; j < n; j++ {
			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