結果
問題 | No.489 株に挑戦 |
ユーザー | tnishinaga |
提出日時 | 2017-02-27 05:20:16 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,779 bytes |
コンパイル時間 | 164 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 24,284 KB |
最終ジャッジ日時 | 2024-06-11 18:38:51 |
合計ジャッジ時間 | 5,315 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 749 ms
24,284 KB |
testcase_01 | AC | 49 ms
16,196 KB |
testcase_02 | AC | 27 ms
10,880 KB |
testcase_03 | AC | 27 ms
11,008 KB |
testcase_04 | AC | 27 ms
11,008 KB |
testcase_05 | AC | 28 ms
11,008 KB |
testcase_06 | AC | 28 ms
10,880 KB |
testcase_07 | AC | 26 ms
11,008 KB |
testcase_08 | AC | 26 ms
11,008 KB |
testcase_09 | AC | 26 ms
11,008 KB |
testcase_10 | AC | 26 ms
11,008 KB |
testcase_11 | AC | 27 ms
11,136 KB |
testcase_12 | AC | 26 ms
11,008 KB |
testcase_13 | AC | 26 ms
10,880 KB |
testcase_14 | AC | 27 ms
11,008 KB |
testcase_15 | AC | 44 ms
11,392 KB |
testcase_16 | AC | 62 ms
19,732 KB |
testcase_17 | AC | 318 ms
12,160 KB |
testcase_18 | TLE | - |
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 | -- | - |
ソースコード
import bisect import sys def problem_input(): inputs = sys.stdin.read() inputs = list(map(int, inputs.split())) n = inputs[0] d = inputs[1] k = inputs[2] xlist = inputs[3:] return n, d, k, xlist def test_input1(): n = 7 d = 2 k = 1000 xlist = [1,3,5,1,4,4,7] return n, d, k, xlist def test_input2(): n = 5 d = 4 k = 100 xlist = [1,2,1,2,1] return n, d, k, xlist def test_input3(): n = 5 d = 1 k = 100 xlist = [5,4,3,3,1] return n, d, k, xlist def bisect_method(n, d, k, xlist): sorted_list = [(xlist[0], 0)] diff_max = 0 result = (0, 0) for i in range(1, n): while (i - sorted_list[0][1]) > d: sorted_list = sorted_list[1:] stock_diff = xlist[i] - sorted_list[0][0] if diff_max < stock_diff: diff_max = stock_diff result = (sorted_list[0][1], i) bisect.insort(sorted_list, (xlist[i], i)) return diff_max, result def sort_method(n, d, k, xlist): minimum = (xlist[0], 0) diff_max = 0 result = (0, 0) for i in range(1, n): # refresh if i - minimum[1] > d: tmp = min(xlist[i-d:i]) minimum = (tmp, xlist.index(tmp)) # max stock_diff = xlist[i] - minimum[0] if diff_max < stock_diff: result = (minimum[1], i) diff_max = stock_diff # min if xlist[i] <= minimum[0]: minimum = (xlist[i], i) return diff_max, result # main n,d,k,xlist = problem_input() # n,d,k,xlist = test_input1() # diff_max, result = bisect_method(n, d, k, xlist) diff_max, result = sort_method(n, d, k, xlist) print(diff_max * k) if diff_max != 0: print("{0} {1}".format(result[0], result[1]))