結果
問題 | No.489 株に挑戦 |
ユーザー |
|
提出日時 | 2017-04-02 04:29:01 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 78 ms / 1,000 ms |
コード長 | 1,061 bytes |
コンパイル時間 | 1,204 ms |
コンパイル使用メモリ | 108,940 KB |
実行使用メモリ | 8,320 KB |
最終ジャッジ日時 | 2024-07-19 23:43:40 |
合計ジャッジ時間 | 3,222 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:52:29: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized] 52 | cout << a << ' ' << b << endl; | ^ main.cpp:35:12: note: 'b' was declared here 35 | int a, b; | ^ main.cpp:52:22: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized] 52 | cout << a << ' ' << b << endl; | ^~~ main.cpp:35:9: note: 'a' was declared here 35 | int a, b; | ^
ソースコード
#define _USE_MATH_DEFINES #include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <complex> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> #include <iterator> using namespace std; int main() { int n, d, k; cin >> n >> d >> k; vector<int> x(n); for(int i=0; i<n; ++i) cin >> x[i]; long long ans = 0; int a, b; multiset<pair<int, int> > ms; for(int i=0; i<n; ++i){ ms.insert(make_pair(x[i], i)); pair<int, int> p = *ms.begin(); if(ans < x[i] - p.first){ ans = x[i] - p.first; a = p.second; b = i; } if(i-d >= 0) ms.erase(make_pair(x[i-d], i-d)); } ans *= k; cout << ans << endl; if(ans > 0) cout << a << ' ' << b << endl; return 0; }