結果
問題 | No.489 株に挑戦 |
ユーザー | Bantako |
提出日時 | 2017-08-18 14:36:51 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.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 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
コンパイルメッセージ
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; }