結果
問題 | No.1117 数列分割 |
ユーザー | vwxyz |
提出日時 | 2024-04-14 12:36:04 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 937 bytes |
コンパイル時間 | 115 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 18,212 KB |
最終ジャッジ日時 | 2024-04-14 12:36:21 |
合計ジャッジ時間 | 11,534 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
18,212 KB |
testcase_01 | AC | 31 ms
11,008 KB |
testcase_02 | AC | 30 ms
10,880 KB |
testcase_03 | AC | 1,580 ms
11,264 KB |
testcase_04 | AC | 1,393 ms
11,264 KB |
testcase_05 | AC | 30 ms
11,008 KB |
testcase_06 | AC | 58 ms
10,880 KB |
testcase_07 | AC | 46 ms
11,136 KB |
testcase_08 | AC | 1,367 ms
11,264 KB |
testcase_09 | AC | 367 ms
11,008 KB |
testcase_10 | AC | 1,462 ms
11,392 KB |
testcase_11 | TLE | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
ソースコード
from collections import deque def Slide_Min(lst,width): queue=deque([]) for i,x in enumerate(lst[:width-1]): while queue and x<=lst[queue[-1]]: queue.pop() queue.append(i) slide_min=[] for i,x in enumerate(lst[width-1:],width-1): while queue and x<=lst[queue[-1]]: queue.pop() queue.append(i) slide_min.append(lst[queue[0]]) if queue[0]==i-width+1: queue.popleft() return slide_min N,K,M=map(int,input().split()) A=[0]+list(map(int,input().split())) for i in range(1,N+1): A[i]+=A[i-1] inf=1<<60 dp=[-inf]*(N+1) dp[0]=0 for k in range(1,K+1): prev=dp dp=[-inf]*(N+1) for i,x in enumerate(Slide_Min([inf]*M+[-A[i]-prev[i] for i in range(N)],M)): dp[i]=max(dp[i],-A[i]-x) for i,x in enumerate(Slide_Min([inf]*M+[A[i]-prev[i] for i in range(N)],M)): dp[i]=max(dp[i],A[i]-x) ans=dp[N] print(ans)