結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 731 ms
355,552 KB
testcase_01 AC 730 ms
355,548 KB
testcase_02 AC 742 ms
355,548 KB
testcase_03 AC 726 ms
355,812 KB
testcase_04 AC 722 ms
355,548 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 674 ms
350,380 KB
testcase_11 AC 249 ms
148,384 KB
testcase_12 AC 252 ms
148,384 KB
testcase_13 WA -
testcase_14 AC 243 ms
148,384 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 13 ms
13,852 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 21 ms
19,324 KB
testcase_23 AC 16 ms
18,220 KB
testcase_24 AC 16 ms
18,216 KB
testcase_25 AC 6 ms
9,728 KB
testcase_26 AC 11 ms
13,848 KB
testcase_27 AC 19 ms
24,280 KB
testcase_28 WA -
testcase_29 AC 14 ms
18,212 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 758 ms
355,028 KB
testcase_35 AC 758 ms
355,548 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 768 ms
355,292 KB
testcase_39 WA -
testcase_40 AC 1 ms
6,944 KB
testcase_41 AC 1 ms
6,944 KB
testcase_42 AC 2 ms
6,944 KB
testcase_43 WA -
testcase_44 AC 1 ms
6,940 KB
testcase_45 WA -
testcase_46 AC 751 ms
355,544 KB
testcase_47 WA -
testcase_48 AC 761 ms
355,540 KB
testcase_49 WA -
testcase_50 AC 743 ms
354,392 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 749 ms
353,488 KB
testcase_54 AC 776 ms
355,544 KB
testcase_55 AC 786 ms
355,544 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)
			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_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