結果

問題 No.489 株に挑戦
ユーザー vjudge1
提出日時 2025-01-31 16:22:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 491 bytes
コンパイル時間 888 ms
コンパイル使用メモリ 62,328 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-31 16:22:27
合計ジャッジ時間 3,046 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
const int N=1e5+10; int a[N],q[N];
int main() {
	//freopen("stock.in","r",stdin);
	//freopen("stock.out","w",stdout);
	ios::sync_with_stdio(false),cin.tie(nullptr);
	int n,d,k,h=1,t=0,ans=0,b,s; cin>>n>>d>>k;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		while(h<=t&&a[q[t]]>a[i]) t--;
		q[++t]=i;
		while(h<=t&&q[h]<i-d) h++;
		if(a[i]-a[q[h]]>ans) ans=a[i]-a[q[h]],b=q[h],s=i;
	}
	if(!ans) cout<<0;
	else cout<<1ll*k*ans<<'\n'<<b-1<<' '<<s-1;
	return 0;
}
0