結果
問題 | No.2139 K Consecutive Sushi |
ユーザー | titia |
提出日時 | 2022-12-03 00:28:31 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 914 bytes |
コンパイル時間 | 439 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 108,324 KB |
最終ジャッジ日時 | 2024-04-18 09:34:58 |
合計ジャッジ時間 | 6,318 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
52,640 KB |
testcase_01 | AC | 33 ms
52,544 KB |
testcase_02 | AC | 33 ms
52,244 KB |
testcase_03 | AC | 236 ms
104,064 KB |
testcase_04 | AC | 264 ms
104,232 KB |
testcase_05 | AC | 255 ms
104,336 KB |
testcase_06 | AC | 246 ms
104,068 KB |
testcase_07 | AC | 257 ms
104,080 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 251 ms
104,608 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | AC | 35 ms
53,132 KB |
testcase_14 | AC | 35 ms
52,868 KB |
testcase_15 | AC | 35 ms
52,744 KB |
testcase_16 | AC | 35 ms
53,216 KB |
testcase_17 | AC | 34 ms
52,128 KB |
testcase_18 | AC | 73 ms
76,560 KB |
testcase_19 | AC | 76 ms
76,400 KB |
testcase_20 | AC | 75 ms
76,488 KB |
testcase_21 | WA | - |
testcase_22 | AC | 81 ms
76,380 KB |
testcase_23 | AC | 109 ms
78,152 KB |
testcase_24 | AC | 146 ms
85,440 KB |
testcase_25 | AC | 199 ms
101,852 KB |
testcase_26 | AC | 107 ms
78,064 KB |
testcase_27 | AC | 144 ms
84,212 KB |
testcase_28 | AC | 143 ms
84,052 KB |
testcase_29 | AC | 118 ms
79,560 KB |
testcase_30 | AC | 153 ms
87,800 KB |
testcase_31 | AC | 239 ms
108,324 KB |
testcase_32 | AC | 121 ms
79,880 KB |
ソースコード
N,K=map(int,input().split()) A=list(map(int,input().split())) seg_el=1<<((N+2).bit_length()) # Segment treeの台の要素数 SEG=[1<<62]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 def update(n,x,seg_el): # A[n]をxへ更新 i=n+seg_el SEG[i]=x i>>=1 # 子ノードへ while i!=0: SEG[i]=min(SEG[i*2],SEG[i*2+1]) i>>=1 def getvalues(l,r): # 区間[l,r)に関するminを調べる L=l+seg_el R=r+seg_el ANS=1<<30 while L<R: if L & 1: ANS=min(ANS , SEG[L]) L+=1 if R & 1: R-=1 ANS=min(ANS , SEG[R]) L>>=1 R>>=1 return ANS update(0,0,seg_el) for i in range(N): a=A[i] u=getvalues(max(0,i+1-K),i+1) update(i+1,u+a,seg_el) ANS=[getvalues(i,i+1) for i in range(N+2)] AS=getvalues(N+1-K,N+1) print(sum(A)-AS)