結果
問題 |
No.489 株に挑戦
|
ユーザー |
|
提出日時 | 2020-02-22 07:37:42 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 36 ms / 1,000 ms |
コード長 | 441 bytes |
コンパイル時間 | 674 ms |
コンパイル使用メモリ | 72,524 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-20 00:19:41 |
合計ジャッジ時間 | 2,429 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main() | ^~~~
ソースコード
#include<iostream> #include<deque> using namespace std; int N,D,K; int x[1<<17]; int ans=-1,ai,aj; main() { cin>>N>>D>>K; deque<int>P; for(int i=0;i<N;i++) { cin>>x[i]; while(!P.empty()&&P.front()+D<i)P.pop_front(); while(!P.empty()&&x[P.back()]>x[i])P.pop_back(); P.push_back(i); if(ans<x[i]-x[P.front()]) { ans=x[aj=i]-x[ai=P.front()]; } } if(ans>0)cout<<(long)K*ans<<endl<<ai<<" "<<aj<<endl; else cout<<0<<endl; }