結果
| 問題 |
No.672 最長AB列
|
| コンテスト | |
| ユーザー |
とばり
|
| 提出日時 | 2018-08-18 17:37:00 |
| 言語 | Go (1.23.4) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 556 bytes |
| コンパイル時間 | 10,614 ms |
| コンパイル使用メモリ | 237,132 KB |
| 実行使用メモリ | 16,068 KB |
| 最終ジャッジ日時 | 2024-11-06 09:16:33 |
| 合計ジャッジ時間 | 13,884 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 14 WA * 2 |
ソースコード
package main
import "fmt"
const MAX_LEN = 200000
func max(a int, b int) int {
if a >= b {
return a
} else {
return b
}
}
func main() {
var S string
fmt.Scan(&S)
scores := [MAX_LEN]int{}
offset := map[rune]int{'A': 1, 'B': -1}
for i, c := range S {
scores[i] += offset[c]
if i > 0 {
scores[i] += scores[i-1]
}
}
table := map[int]int{}
ans := 0
for l := len(S) - 1; l >= 0; l-- {
table[scores[l]] = max(table[scores[l]], l)
r := table[scores[l] - offset[rune(S[l])]]
ans = max(ans, r - l + 1)
}
fmt.Println(ans)
}
とばり