結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
rickytheta
|
| 提出日時 | 2017-02-24 22:37:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,051 bytes |
| コンパイル時間 | 1,707 ms |
| コンパイル使用メモリ | 159,380 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2025-01-02 23:07:12 |
| 合計ジャッジ時間 | 3,038 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 32 WA * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
28 | scanf("%d%d%d",&n,&d,&k);
| ~~~~~^~~~~~~~~~~~~~~~~~~
main.cpp:29:16: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
29 | REP(i,n)scanf("%d",x+i);
| ~~~~~^~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)
#define ALL(a) (a).begin(),(a).end()
#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))
int n,d,k;
int x[125252];
void ins(deque<int> &Q, int i){
if(i>=n)return;
while(!Q.empty() && x[Q.back()]<x[i])Q.pop_back();
Q.push_back(i);
}
int main(){
scanf("%d%d%d",&n,&d,&k);
REP(i,n)scanf("%d",x+i);
deque<int> Q;
REP(i,d+1)ins(Q,i);
ll ans = -1;
int a,b;
REP(i,n){
// buy at i
ll buy = (ll)x[i]*k;
ll sell = (ll)x[Q.front()]*k;
if(sell-buy > ans){
ans = sell-buy;
a = i;
b = Q.front();
}
if(Q.front()==i)Q.pop_front();
ins(Q,i+d+1);
}
if(ans==-1){
puts("0");
}else{
printf("%lld\n%d %d\n",ans,a,b);
}
}
rickytheta