結果
問題 | No.1188 レベルX門松列 |
ユーザー | dot_haraai |
提出日時 | 2021-03-28 12:39:06 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 83 ms / 2,000 ms |
コード長 | 2,794 bytes |
コンパイル時間 | 3,932 ms |
コンパイル使用メモリ | 87,180 KB |
実行使用メモリ | 15,232 KB |
最終ジャッジ日時 | 2024-05-06 22:36:02 |
合計ジャッジ時間 | 5,098 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 69 ms
13,952 KB |
testcase_01 | AC | 72 ms
13,184 KB |
testcase_02 | AC | 63 ms
11,520 KB |
testcase_03 | AC | 83 ms
14,848 KB |
testcase_04 | AC | 74 ms
14,848 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 47 ms
13,312 KB |
testcase_07 | AC | 72 ms
13,952 KB |
testcase_08 | AC | 72 ms
13,952 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
testcase_11 | AC | 7 ms
5,376 KB |
testcase_12 | AC | 7 ms
5,376 KB |
testcase_13 | AC | 7 ms
5,376 KB |
testcase_14 | AC | 45 ms
10,112 KB |
testcase_15 | AC | 82 ms
15,232 KB |
testcase_16 | AC | 2 ms
5,376 KB |
testcase_17 | AC | 64 ms
12,032 KB |
testcase_18 | AC | 2 ms
5,376 KB |
testcase_19 | AC | 62 ms
11,648 KB |
testcase_20 | AC | 2 ms
5,376 KB |
testcase_21 | AC | 2 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
/home/judge/data/code/Main.nim(2, 18) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated] /home/judge/data/code/Main.nim(1, 8) Warning: imported and not used: 'times' [UnusedImport] /home/judge/data/code/Main.nim(2, 26) Warning: imported and not used: 'strformat' [UnusedImport] /home/judge/data/code/Main.nim(2, 18) Warning: imported and not used: 'future' [UnusedImport] /home/judge/data/code/Main.nim(2, 37) Warning: imported and not used: 'deques' [UnusedImport] /home/judge/data/code/Main.nim(2, 8) Warning: imported and not used: 'critbits' [UnusedImport] /home/judge/data/code/Main.nim(1, 52) Warning: imported and not used: 'tables' [UnusedImport] /home/judge/data/code/Main.nim(1, 60) Warning: imported and not used: 'sets' [UnusedImport] /home/judge/data/code/Main.nim(1, 66) Warning: imported and not used: 'lists' [UnusedImport] /home/judge/data/code/Main.nim(1, 73) Warning: imported and not used: 'intsets' [UnusedImport]
ソースコード
import times, strutils, sequtils, math, algorithm, tables, sets, lists, intsets import critbits, future, strformat, deques template `max=`(x,y) = x = max(x,y) template `min=`(x,y) = x = min(x,y) template `mod=`(x,y) = x = x mod y template scan2 = (scan(), scan()) template scan3 = (scan(), scan()) let read* = iterator: string {.closure.} = while true: (for s in stdin.readLine.split: yield s) proc scan(): int = read().parseInt proc scanf(): float = read().parseFloat proc toInt(c:char): int = return int(c) - int('0') proc getLIS(arr:seq[int]):seq[int]= var n = arr.len result = newseqwith(n+2,int.high.div(2)) result[0]=arr[0] proc binSearch(v:int,res:var seq[int]):int= var left = 0 right = n+1 if res[left]>v: return left else: while left+1<right: var mid = (left+right).div(2) if res[mid]<=v: left = mid else: right=mid return right #echo getLIS(@[1,3,5,2,4,6]) proc solve():int= var inf = int.high.div(2) n = scan() a = newseqwith(n,scan()) # 左から単調増加 lisA = newseqwith(n+1,inf) resA = newseqwith(n,0) inva = a.reversed() # 右から単調増加 lisInvA = newseqwith(n+1,inf) resInvA = newseqwith(n,0) b = a.mapIt(-it) # 左から単調減少 lisB = newseqwith(n+1,inf) resB = newseqwith(n,0) invb = b.reversed() # 右から単調減少 lisInvB = newseqwith(n+1,inf) resInvB = newseqwith(n,0) proc binSearch(v:int,res:var seq[int]):int= var left = 0 right = n+1 if res[left]>=v: return left else: while left+1<right: var mid = (left+right).div(2) if res[mid]<v: left = mid else: right=mid return right proc getMinVal(arr:var seq[int]):int= var left = 0 right = n+1 if arr[left]==inf: return left else: while left+1<right: var mid = (left+right).div(2) if arr[mid]==inf: right=mid else: left = mid return left for i in 0..<n: # LISの更新 lisA[binSearch(a[i],lisA)]=a[i] lisInvA[binSearch(inva[i],lisInvA)]=inva[i] lisB[binSearch(b[i],lisB)]=b[i] lisInvB[binSearch(invb[i],lisInvB)]=invb[i] #echo lisA resA[i]=getMinVal(lisA)+1 resB[i]=getMinVal(lisB)+1 resInvA[n-i-1]=getMinVal(lisInvA)+1 resInvB[n-1-i]=getMinVal(lisInvB)+1 #echo resA , "単調増加列(iまで)" #echo resB, "単調減少列(iまで)" #echo resInvA, "単調減少列(iから)" #echo resInvB, "単調増加列(iから)" for i in 0..<n: result.max=min(resA[i],resInvA[i])-1 result.max=min(resB[i],resInvB[i])-1 return echo solve()