結果
問題 | No.1188 レベルX門松列 |
ユーザー | ccppjsrb |
提出日時 | 2020-08-22 16:42:30 |
言語 | Go (1.22.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,699 bytes |
コンパイル時間 | 12,313 ms |
コンパイル使用メモリ | 238,464 KB |
実行使用メモリ | 8,960 KB |
最終ジャッジ日時 | 2024-10-15 10:36:32 |
合計ジャッジ時間 | 14,068 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | AC | 48 ms
8,704 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | WA | - |
testcase_07 | AC | 48 ms
8,576 KB |
testcase_08 | AC | 47 ms
8,576 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 2 ms
5,248 KB |
testcase_11 | AC | 5 ms
5,248 KB |
testcase_12 | WA | - |
testcase_13 | AC | 5 ms
5,248 KB |
testcase_14 | AC | 33 ms
5,632 KB |
testcase_15 | AC | 56 ms
8,192 KB |
testcase_16 | AC | 1 ms
5,248 KB |
testcase_17 | AC | 44 ms
6,784 KB |
testcase_18 | AC | 1 ms
5,248 KB |
testcase_19 | AC | 41 ms
6,400 KB |
testcase_20 | AC | 1 ms
5,248 KB |
testcase_21 | AC | 1 ms
5,248 KB |
testcase_22 | AC | 1 ms
5,248 KB |
testcase_23 | AC | 1 ms
5,248 KB |
ソースコード
package main import ( "bufio" "fmt" "math" "os" "strconv" ) func configure(scanner *bufio.Scanner) { scanner.Split(bufio.ScanWords) scanner.Buffer(make([]byte, 1000005), 1000005) } func getNextString(scanner *bufio.Scanner) string { scanned := scanner.Scan() if !scanned { panic("scan failed") } return scanner.Text() } func getNextInt(scanner *bufio.Scanner) int { i, _ := strconv.Atoi(getNextString(scanner)) return i } func getNextInt64(scanner *bufio.Scanner) int64 { i, _ := strconv.ParseInt(getNextString(scanner), 10, 64) return i } func getNextFloat64(scanner *bufio.Scanner) float64 { i, _ := strconv.ParseFloat(getNextString(scanner), 64) return i } func main() { fp := os.Stdin wfp := os.Stdout extra := 0 if os.Getenv("I") == "IronMan" { fp, _ = os.Open(os.Getenv("END_GAME")) extra = 100 } scanner := bufio.NewScanner(fp) configure(scanner) writer := bufio.NewWriter(wfp) defer func() { r := recover() if r != nil { fmt.Fprintln(writer, r) } writer.Flush() }() solve(scanner, writer) for i := 0; i < extra; i++ { fmt.Fprintln(writer, "-----------------------------------") solve(scanner, writer) } } func solve(scanner *bufio.Scanner, writer *bufio.Writer) { n := getNextInt(scanner) aa := make([]int, n) for i := 0; i < n; i++ { aa[i] = getNextInt(scanner) } ll := make([]int, n) rr := make([]int, n) lll := make([]int, n) rrr := make([]int, n) yokubalis := make([]int, n) yokubalisugi := make([]int, n) yokubalisugiya := make([]int, n) yokubalisugiyaro := make([]int, n) for i := 0; i < n; i++ { yokubalis[i] = math.MaxInt32 yokubalisugi[i] = math.MaxInt32 // yokubalisugiya[i] = math.MaxInt32 // yokubalisugiyaro[i] = math.MaxInt32 } for i := 0; i < n; i++ { r := lower(n, aa[i], yokubalis, func(a, b int) bool { return a < b }) ll[i] = r } for i := 0; i < n; i++ { r := lower(n, aa[i], yokubalisugiya, func(a, b int) bool { return a > b }) lll[i] = r } for i := n - 1; i >= 0; i-- { r := lower(n, aa[i], yokubalisugi, func(a, b int) bool { return a < b }) rr[i] = r } for i := n - 1; i >= 0; i-- { r := lower(n, aa[i], yokubalisugiyaro, func(a, b int) bool { return a > b }) rrr[i] = r } var ans int for i := 0; i < n; i++ { ans = max(ans, min(ll[i], rr[i])) ans = max(ans, min(lll[i], rrr[i])) } fmt.Fprintln(writer, ans) } func min(a, b int) int { if a < b { return a } return b } func max(a, b int) int { return -min(-a, -b) } func lower(n, a int, yokubalis []int, less func(int, int) bool) int { l := -1 r := n for l+1 < r { m := (l + r) >> 1 if less(a, yokubalis[m]) { r = m continue } l = m } yokubalis[r] = a return r }