結果
問題 |
No.489 株に挑戦
|
ユーザー |
![]() |
提出日時 | 2025-01-29 12:23:27 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 14 ms / 1,000 ms |
コード長 | 527 bytes |
コンパイル時間 | 2,036 ms |
コンパイル使用メモリ | 191,980 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2025-01-29 12:23:32 |
合計ジャッジ時間 | 4,225 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | scanf("%d%d%d",&n,&d,&k); | ~~~~~^~~~~~~~~~~~~~~~~~~ main.cpp:7:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | for(int i=0;i<n;++i)scanf("%d",&x[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h> using namespace std; int x[100005],q[100005]; int main(){ int n,d,k; scanf("%d%d%d",&n,&d,&k); for(int i=0;i<n;++i)scanf("%d",&x[i]); int hd=1,tl=0; long long ans=0; int u=0,v=0; for(int i=n-1;i>=0;--i){ while(hd<=tl&&q[hd]>i+d)++hd; while(hd<=tl&&x[q[tl]]<=x[i])--tl; q[++tl]=i; if(hd<=tl){ long long an=1ll*(x[q[hd]]-x[i])*k; if(ans<=an){ ans=an; u=i,v=q[hd]; } } } if(ans==0){ puts("0"); return 0; } printf("%lld\n",ans); printf("%d %d\n",u,v); return 0; }