結果
問題 | No.489 株に挑戦 |
ユーザー | hanorver |
提出日時 | 2017-03-01 22:03:06 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 927 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 10,968 KB |
実行使用メモリ | 18,816 KB |
最終ジャッジ日時 | 2023-09-03 17:10:53 |
合計ジャッジ時間 | 6,716 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | TLE | - |
testcase_02 | AC | 14 ms
8,332 KB |
testcase_03 | AC | 14 ms
8,180 KB |
testcase_04 | AC | 13 ms
8,204 KB |
testcase_05 | AC | 15 ms
8,276 KB |
testcase_06 | AC | 13 ms
8,276 KB |
testcase_07 | AC | 13 ms
8,388 KB |
testcase_08 | AC | 14 ms
8,272 KB |
testcase_09 | AC | 15 ms
8,196 KB |
testcase_10 | AC | 16 ms
8,312 KB |
testcase_11 | AC | 15 ms
8,392 KB |
testcase_12 | AC | 15 ms
8,164 KB |
testcase_13 | AC | 16 ms
8,392 KB |
testcase_14 | AC | 15 ms
8,220 KB |
testcase_15 | AC | 43 ms
9,044 KB |
testcase_16 | TLE | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
ソースコード
INF=-1000000007 SQRT_N = 512 N,D,K = map(int,input().split()) x = [int(input()) for i in range(N)] b_size = (N + SQRT_N - 1) // SQRT_N bucket = [(INF,INF) for i in range(b_size * SQRT_N)] bucketMax = [(INF,INF) for i in range(b_size)] def query(left,right): ret = (INF,INF) for i in range(left // SQRT_N, right // SQRT_N + 1): l = i * SQRT_N r = (i+1) * SQRT_N if right <= l: break if r <= left or right <= l: continue if left <= l and r <= right: ret = max(ret,bucketMax[i]) else: s,t = max(left,l),min(right,r) ret = max(ret, max(bucket[s:t])) return ret for i in range(N): bucket[i] = (x[i],-i) for i in range(N): k = i // SQRT_N bucketMax[k] = max(bucketMax[k],bucket[i]) ans,pair = 0,() for i in range(N-1): ret = query(i+1,min(N,i+D+1)) if ans < ret[0]-x[i]: ans = ret[0]-x[i] pair = (i,-ret[1]) if ans <= 0: print(0) else: print(ans*K) print(' '.join([str(_) for _ in pair]))