結果
問題 | No.489 株に挑戦 |
ユーザー |
![]() |
提出日時 | 2017-06-30 11:51:49 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 48 ms / 1,000 ms |
コード長 | 695 bytes |
コンパイル時間 | 539 ms |
コンパイル使用メモリ | 44,416 KB |
実行使用メモリ | 7,936 KB |
最終ジャッジ日時 | 2024-07-19 23:54:39 |
合計ジャッジ時間 | 1,870 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:22:43: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 22 | for(int i=0;i<n;i++) scanf("%d", &x[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include<cstdio>#include<vector>#include<set>using namespace std;using vi=vector<int>;using ll=long long;int main(void){int n, d, k;while(scanf("%d%d%d", &n, &d, &k)==3){vi x(n);multiset<int> m;int b, s, e, x_min;int b_max=0, s_max, e_max;for(int i=0;i<n;i++) scanf("%d", &x[i]);for(s=e=0;e<n;e++){m.insert(x[e]);if(e-s>d){m.erase(m.find(x[s]));s++;}x_min=*m.begin();b=x[e]-x_min;if(b_max<b){b_max=b;e_max=e;for(s_max=s;s_max<=e;s_max++){if(x[s_max]==x_min) break;}}}printf("%lld\n", (ll)b_max*k);if(b_max){printf("%d %d\n", s_max, e_max);}}return 0;}