結果

問題 No.1188 レベルX門松列
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-23 01:28:40
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,163 bytes
コンパイル時間 2,138 ms
コンパイル使用メモリ 150,236 KB
実行使用メモリ 6,840 KB
最終ジャッジ日時 2023-10-14 17:22:52
合計ジャッジ時間 4,464 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
6,536 KB
testcase_01 AC 92 ms
5,916 KB
testcase_02 AC 81 ms
6,048 KB
testcase_03 AC 110 ms
6,840 KB
testcase_04 AC 108 ms
6,776 KB
testcase_05 AC 2 ms
4,352 KB
testcase_06 AC 91 ms
6,780 KB
testcase_07 AC 103 ms
6,532 KB
testcase_08 AC 102 ms
6,536 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 9 ms
4,352 KB
testcase_12 AC 9 ms
4,348 KB
testcase_13 AC 10 ms
4,352 KB
testcase_14 AC 66 ms
5,288 KB
testcase_15 AC 115 ms
6,728 KB
testcase_16 AC 3 ms
4,352 KB
testcase_17 AC 91 ms
6,080 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 84 ms
5,720 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

func main()
	var n: int :: cui@inputInt()
	var a: []int :: #[n]int
	for i(0, n - 1)
		do a[i] :: cui@inputInt()
	end for
	
	var ans: int :: solve(a)
	for i(0, n - 1)
		do a[i] :: -1 * a[i]
	end for
	do ans :: lib@max(ans, solve(a))
	do cui@print("\{ans}\n")
	
	func solve(a: []int): int
		var lis: []int :: getLisArr(a)
		do a.reverse()
		var revLis: []int :: getLisArr(a)
		do revLis.reverse()
		do a.reverse()
		var res: int :: 0
		for i(0, ^a - 1)
			do res :: lib@max(res, lib@min(lis[i], revLis[i]) - 1)
		end for
		ret res
		
		func getLisArr(a: []int): []int
			const infInt: int :: lib@intMax
			var n: int :: ^a
			var buff: []int :: [infInt].repeat(n + 1)
			var lisArr: []int :: #[n]int
			for i(0, n - 1)
				var idx: int :: f(buff, a[i])
				do buff[idx] :: a[i]
				do lisArr[i] :: f(buff, infInt)
				
				func f(arr: []int, val: int): int
					var ok: int :: -1
					var ng: int :: ^arr - 1
					while((ok - ng).abs() > 1)
						var mid: int :: (ok + ng) / 2
						if(val > arr[mid])
							do ok :: mid
						else
							do ng :: mid
						end if
					end while
					ret ok + 1
				end func
			end for
			ret lisArr
		end func
	end func
end func
0