結果
| 問題 | No.489 株に挑戦 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-01-30 21:44:58 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.90.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 1,000 ms |
| コード長 | 628 bytes |
| 記録 | |
| コンパイル時間 | 1,942 ms |
| コンパイル使用メモリ | 209,364 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-27 00:58:34 |
| 合計ジャッジ時間 | 3,511 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#include<bits/stdc++.h>
#define FL(i,a,b) for(ll i=(a);i<=(b);i++)
#define FR(i,a,b) for(ll i=(a);i>=(b);i--)
#define ll long long
#define PII pair<ll,ll>
using namespace std;
const ll MAXN = 1e5 + 10;
ll a[MAXN],q[MAXN];
PII pos;
signed main(){
ll n,D,K,ans=0;
scanf("%lld%lld%lld",&n,&D,&K);
FL(i,1,n) scanf("%lld",&a[i]);
ll l=1,r=0;
FL(i,1,n){
while(l<=r&&i-q[l]>D) l++;
while(l<=r&&a[q[r]]>a[i]) r--;
if(l<=r){
ll res=(a[i]-a[q[l]])*K;
if(res>ans){
ans=res;
pos={q[l],i};
}
}
q[++r]=i;
}
if(!ans) puts("0"),exit(0);
printf("%lld\n",ans);
printf("%lld %lld\n",pos.first-1,pos.second-1);
}
vjudge1