結果

問題 No.1188 レベルX門松列
ユーザー dot_haraaidot_haraai
提出日時 2021-03-28 12:23:53
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 2,788 bytes
コンパイル時間 6,096 ms
コンパイル使用メモリ 86,912 KB
実行使用メモリ 15,104 KB
最終ジャッジ日時 2024-11-29 08:59:18
合計ジャッジ時間 7,338 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 78 ms
13,184 KB
testcase_02 AC 69 ms
11,520 KB
testcase_03 AC 94 ms
14,848 KB
testcase_04 AC 81 ms
14,848 KB
testcase_05 AC 2 ms
5,248 KB
testcase_06 WA -
testcase_07 AC 78 ms
13,952 KB
testcase_08 AC 77 ms
13,952 KB
testcase_09 AC 2 ms
5,248 KB
testcase_10 AC 1 ms
5,248 KB
testcase_11 AC 7 ms
5,248 KB
testcase_12 AC 7 ms
5,248 KB
testcase_13 AC 8 ms
5,248 KB
testcase_14 AC 50 ms
9,984 KB
testcase_15 AC 91 ms
15,104 KB
testcase_16 AC 2 ms
5,248 KB
testcase_17 AC 69 ms
12,032 KB
testcase_18 AC 1 ms
5,248 KB
testcase_19 AC 67 ms
11,648 KB
testcase_20 AC 2 ms
5,248 KB
testcase_21 AC 2 ms
5,248 KB
testcase_22 AC 2 ms
5,248 KB
testcase_23 AC 2 ms
5,248 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]

ソースコード

diff #

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]
    # 
    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()
0