結果
問題 | No.489 株に挑戦 |
ユーザー | titia |
提出日時 | 2023-06-13 01:13:51 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 794 ms / 1,000 ms |
コード長 | 1,432 bytes |
コンパイル時間 | 276 ms |
コンパイル使用メモリ | 10,992 KB |
実行使用メモリ | 14,444 KB |
最終ジャッジ日時 | 2023-09-02 17:52:00 |
合計ジャッジ時間 | 13,131 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 478 ms
13,208 KB |
testcase_01 | AC | 392 ms
11,260 KB |
testcase_02 | AC | 15 ms
8,272 KB |
testcase_03 | AC | 16 ms
8,304 KB |
testcase_04 | AC | 16 ms
8,364 KB |
testcase_05 | AC | 16 ms
8,276 KB |
testcase_06 | AC | 16 ms
8,360 KB |
testcase_07 | AC | 16 ms
8,220 KB |
testcase_08 | AC | 16 ms
8,248 KB |
testcase_09 | AC | 16 ms
8,312 KB |
testcase_10 | AC | 16 ms
8,372 KB |
testcase_11 | AC | 16 ms
8,316 KB |
testcase_12 | AC | 16 ms
8,340 KB |
testcase_13 | AC | 15 ms
8,220 KB |
testcase_14 | AC | 15 ms
8,136 KB |
testcase_15 | AC | 38 ms
8,588 KB |
testcase_16 | AC | 709 ms
13,708 KB |
testcase_17 | AC | 55 ms
9,156 KB |
testcase_18 | AC | 369 ms
11,400 KB |
testcase_19 | AC | 328 ms
10,844 KB |
testcase_20 | AC | 760 ms
13,952 KB |
testcase_21 | AC | 176 ms
9,532 KB |
testcase_22 | AC | 57 ms
8,748 KB |
testcase_23 | AC | 275 ms
11,548 KB |
testcase_24 | AC | 794 ms
14,444 KB |
testcase_25 | AC | 16 ms
8,240 KB |
testcase_26 | AC | 767 ms
14,404 KB |
testcase_27 | AC | 674 ms
14,272 KB |
testcase_28 | AC | 16 ms
8,332 KB |
testcase_29 | AC | 15 ms
8,212 KB |
testcase_30 | AC | 776 ms
14,432 KB |
testcase_31 | AC | 771 ms
14,204 KB |
testcase_32 | AC | 373 ms
11,572 KB |
testcase_33 | AC | 777 ms
14,192 KB |
testcase_34 | AC | 654 ms
13,500 KB |
testcase_35 | AC | 262 ms
10,636 KB |
testcase_36 | AC | 103 ms
9,132 KB |
testcase_37 | AC | 414 ms
11,456 KB |
ソースコード
import sys input = sys.stdin.readline N,D,K=map(int,input().split()) A=[int(input()) for i in range(N)] # Segment tree(1-indexed,再帰を使わないもの。非可換の場合にも対応) def seg_function(x,y): # Segment treeで扱うfunction return max(x,y) seg_el=1<<(N.bit_length()) # Segment treeの台の要素数 SEG=[0]*(2*seg_el) # 1-indexedなので、要素数2*seg_el.Segment treeの初期値で初期化 for i in range(N): # Aを対応する箇所へupdate SEG[i+seg_el]=A[i] for i in range(seg_el-1,0,-1): # 親の部分もupdate SEG[i]=seg_function(SEG[i*2],SEG[i*2+1]) def update(n,x,seg_el): # A[n]をxへ更新 i=n+seg_el SEG[i]=x i>>=1 # 子ノードへ while i!=0: SEG[i]=seg_function(SEG[i*2],SEG[i*2+1]) i>>=1 def getvalues(l,r): # 区間[l,r)に関するseg_functionを調べる L=l+seg_el R=r+seg_el ANS1=0 ANS2=0 while L<R: if L & 1: ANS1=seg_function(ANS1, SEG[L]) L+=1 if R & 1: R-=1 ANS2=seg_function(SEG[R], ANS2) L>>=1 R>>=1 return seg_function(ANS1, ANS2) ANS=-1<<60 for i in range(N): x=getvalues(i+1,min(N,i+D+1)) if ANS<x-A[i]: ANS=x-A[i] ind=i if ANS<=0: print(0) exit() for j in range(ind,ind+D+1): if A[j]-A[ind]==ANS: print(ANS*K) print(ind,j) break