結果

問題 No.1188 レベルX門松列
ユーザー 👑 tatt61880tatt61880
提出日時 2021-02-23 01:27:05
言語 Kuin
(KuinC++ v.2021.9.17)
結果
AC  
実行時間 116 ms / 2,000 ms
コード長 1,136 bytes
コンパイル時間 2,298 ms
コンパイル使用メモリ 149,620 KB
実行使用メモリ 6,852 KB
最終ジャッジ日時 2023-10-14 17:22:47
合計ジャッジ時間 4,591 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
6,676 KB
testcase_01 AC 92 ms
6,048 KB
testcase_02 AC 81 ms
5,944 KB
testcase_03 AC 111 ms
6,792 KB
testcase_04 AC 107 ms
6,624 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 91 ms
6,712 KB
testcase_07 AC 103 ms
6,852 KB
testcase_08 AC 103 ms
6,648 KB
testcase_09 AC 2 ms
4,352 KB
testcase_10 AC 2 ms
4,352 KB
testcase_11 AC 10 ms
4,348 KB
testcase_12 AC 9 ms
4,348 KB
testcase_13 AC 10 ms
4,352 KB
testcase_14 AC 67 ms
5,448 KB
testcase_15 AC 116 ms
6,668 KB
testcase_16 AC 3 ms
4,352 KB
testcase_17 AC 90 ms
6,084 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 84 ms
5,944 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,352 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
	end func
	
	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
0