結果

問題 No.973 余興
ユーザー SugihaMSugihaM
提出日時 2020-04-22 17:14:01
言語 Go
(1.22.1)
結果
WA  
実行時間 -
コード長 1,752 bytes
コンパイル時間 11,442 ms
コンパイル使用メモリ 226,624 KB
実行使用メモリ 385,632 KB
最終ジャッジ日時 2024-04-20 01:52:33
合計ジャッジ時間 35,650 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 737 ms
298,460 KB
testcase_01 AC 707 ms
359,256 KB
testcase_02 AC 697 ms
359,136 KB
testcase_03 AC 674 ms
359,516 KB
testcase_04 AC 679 ms
359,260 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 644 ms
354,092 KB
testcase_11 AC 235 ms
244,716 KB
testcase_12 AC 225 ms
242,872 KB
testcase_13 WA -
testcase_14 AC 229 ms
244,720 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 25 ms
67,660 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 36 ms
84,132 KB
testcase_23 AC 30 ms
74,052 KB
testcase_24 AC 29 ms
75,892 KB
testcase_25 AC 17 ms
51,128 KB
testcase_26 AC 26 ms
65,604 KB
testcase_27 AC 36 ms
90,308 KB
testcase_28 WA -
testcase_29 AC 29 ms
75,888 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 642 ms
358,744 KB
testcase_35 AC 651 ms
359,260 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 644 ms
359,004 KB
testcase_39 WA -
testcase_40 AC 1 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 1 ms
6,940 KB
testcase_45 WA -
testcase_46 AC 661 ms
359,256 KB
testcase_47 WA -
testcase_48 AC 647 ms
359,260 KB
testcase_49 WA -
testcase_50 AC 653 ms
358,100 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 651 ms
357,208 KB
testcase_54 AC 669 ms
359,260 KB
testcase_55 AC 666 ms
359,132 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
	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, 5000)
	for i := 0; i < n; i++ {
		dp_l[i] = make([]int, 5001)
	}
	dp_r := make([][]int, 5000)
	for i := 0; i < n; i++ {
		dp_r[i] = make([]int, 5001)
	}
	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)
			p := dp_r[right][i-1] - dp_r[right][i-count-1]
			if p != 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)
			p = dp_l[left][i-1] - dp_l[left][i-count-1]
			if p != 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