結果
問題 | No.1188 レベルX門松列 |
ユーザー | ccppjsrb |
提出日時 | 2020-08-22 16:44:40 |
言語 | Go (1.22.1) |
結果 |
AC
|
実行時間 | 54 ms / 2,000 ms |
コード長 | 2,623 bytes |
コンパイル時間 | 13,721 ms |
コンパイル使用メモリ | 219,780 KB |
実行使用メモリ | 8,704 KB |
最終ジャッジ日時 | 2024-10-15 10:43:41 |
合計ジャッジ時間 | 15,262 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
7,808 KB |
testcase_01 | AC | 44 ms
6,912 KB |
testcase_02 | AC | 38 ms
6,400 KB |
testcase_03 | AC | 52 ms
7,936 KB |
testcase_04 | AC | 44 ms
8,704 KB |
testcase_05 | AC | 1 ms
5,248 KB |
testcase_06 | AC | 29 ms
7,424 KB |
testcase_07 | AC | 45 ms
8,576 KB |
testcase_08 | AC | 44 ms
8,576 KB |
testcase_09 | AC | 1 ms
5,248 KB |
testcase_10 | AC | 1 ms
5,248 KB |
testcase_11 | AC | 4 ms
5,248 KB |
testcase_12 | AC | 4 ms
5,248 KB |
testcase_13 | AC | 5 ms
5,248 KB |
testcase_14 | AC | 32 ms
5,504 KB |
testcase_15 | AC | 54 ms
8,192 KB |
testcase_16 | AC | 2 ms
5,248 KB |
testcase_17 | AC | 41 ms
6,784 KB |
testcase_18 | AC | 2 ms
5,248 KB |
testcase_19 | AC | 40 ms
6,528 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 } 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 }