結果

問題 No.973 余興
ユーザー SugihaMSugihaM
提出日時 2020-04-22 17:26:52
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,611 bytes
コンパイル時間 11,885 ms
コンパイル使用メモリ 231,192 KB
実行使用メモリ 269,596 KB
最終ジャッジ日時 2024-04-20 02:12:14
合計ジャッジ時間 31,950 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 576 ms
268,008 KB
testcase_01 AC 520 ms
268,188 KB
testcase_02 AC 505 ms
267,880 KB
testcase_03 AC 521 ms
267,808 KB
testcase_04 AC 493 ms
268,196 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 507 ms
260,772 KB
testcase_11 AC 165 ms
143,464 KB
testcase_12 AC 170 ms
143,592 KB
testcase_13 WA -
testcase_14 AC 180 ms
143,008 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 18 ms
67,436 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 27 ms
78,444 KB
testcase_23 AC 23 ms
75,624 KB
testcase_24 AC 22 ms
75,624 KB
testcase_25 AC 14 ms
53,096 KB
testcase_26 AC 20 ms
67,436 KB
testcase_27 AC 29 ms
79,776 KB
testcase_28 WA -
testcase_29 AC 23 ms
75,628 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 492 ms
268,912 KB
testcase_35 AC 539 ms
269,596 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 513 ms
269,088 KB
testcase_39 WA -
testcase_40 AC 2 ms
6,940 KB
testcase_41 AC 2 ms
6,940 KB
testcase_42 AC 2 ms
6,940 KB
testcase_43 WA -
testcase_44 AC 2 ms
6,940 KB
testcase_45 WA -
testcase_46 AC 557 ms
268,140 KB
testcase_47 WA -
testcase_48 AC 506 ms
268,008 KB
testcase_49 WA -
testcase_50 AC 495 ms
266,476 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 543 ms
264,812 KB
testcase_54 AC 526 ms
268,012 KB
testcase_55 AC 529 ms
267,676 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, 5000)
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(Scanner())
	}

	l := make([]int, 5000)
	r := make([]int, 5000)
	sum := 0
	b := 0
	c := 0

	for b != n {
		for c != n && sum+a[c] <= x {
			sum += a[c]
			c++
		}
		l[b] = c - b
		sum -= a[b]
		b++
	}
	b = n - 1
	c = n - 1
	sum = 0
	for c >= 0 {
		for b != 0 && sum+a[b] <= x {
			sum += a[b]
			b--
		}
		r[c] = c - b
		sum -= a[c]
		c--
	}
	dp_l := [5000][5001]int{}
	dp_r := [5000][5001]int{}
	left := 0
	right := 0
	q := 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
			}
			q = min(l[left], i-1)
			p := dp_r[right][i-1] - dp_r[right][i-q-1]
			if p != q {
				dp_l[left][i] = dp_l[left][i-1] + 1
				dp_r[right][i] = dp_r[right][i-1] + 1
				continue
			}

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