結果
問題 |
No.489 株に挑戦
|
ユーザー |
![]() |
提出日時 | 2017-08-18 14:36:51 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,388 bytes |
コンパイル時間 | 1,773 ms |
コンパイル使用メモリ | 174,592 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-14 14:55:22 |
合計ジャッジ時間 | 4,048 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 3 |
other | WA * 35 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main(){ | ^~~~ main.cpp: In function 'int main()': main.cpp:49:37: warning: 'maxi' may be used uninitialized [-Wmaybe-uninitialized] 49 | if(!maxd)cout << mini << " " << maxi << endl; | ^~~~ main.cpp:11:43: note: 'maxi' was declared here 11 | int minn = INF,maxn = 0,maxd = 0,mini,maxi; | ^~~~ main.cpp:49:30: warning: 'mini' may be used uninitialized [-Wmaybe-uninitialized] 49 | if(!maxd)cout << mini << " " << maxi << endl; | ^~~ main.cpp:11:38: note: 'mini' was declared here 11 | int minn = INF,maxn = 0,maxd = 0,mini,maxi; | ^~~~
ソースコード
#include<bits/stdc++.h> typedef long long ll; using namespace std; typedef pair<int, int> p; int INF = 1e9; int MOD = 1e9+7; main(){ ll N,D,K,X[100000]; cin >> N >> D >> K; for(int i = 0;i < N;i++)cin >> X[i]; int minn = INF,maxn = 0,maxd = 0,mini,maxi; priority_queue<p> bq;//降順 priority_queue<p,vector<p>,greater<p> > sq;//昇順 for(int i = 0;i <= D;i++){ bq.push(p(X[i],i)); sq.push(p(X[i],i)); /* if(minn > X[i]){ minn = X[i]; mini = i; } if(maxn < X[i]){ maxn = X[i]; maxi = i; } maxd = max(maxd,maxn-minn); */ while(bq.top().second < sq.top().second){ sq.pop(); } if(maxd < bq.top().first-sq.top().first){ maxd = bq.top().first-sq.top().first; maxi = bq.top().second; mini = sq.top().second; } } for(int i = D+1;i < N;i++){ bq.push(p(X[i],i)); sq.push(p(X[i],i)); while(bq.top().second <= i-D)bq.pop(); while(sq.top().second <= i-D)sq.pop(); if(maxd < bq.top().first-sq.top().first){ maxd = bq.top().first-sq.top().first; maxi = bq.top().second; mini = sq.top().second; } } cout << maxd*K << endl; if(!maxd)cout << mini << " " << maxi << endl; }