結果
問題 | No.489 株に挑戦 |
ユーザー | tekitouk |
提出日時 | 2017-02-25 20:02:27 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,489 bytes |
コンパイル時間 | 603 ms |
コンパイル使用メモリ | 76,860 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-11 15:02:25 |
合計ジャッジ時間 | 1,863 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
6,816 KB |
testcase_01 | AC | 7 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,944 KB |
testcase_07 | AC | 1 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,944 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 1 ms
6,944 KB |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,944 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 11 ms
6,940 KB |
testcase_17 | WA | - |
testcase_18 | AC | 6 ms
6,944 KB |
testcase_19 | AC | 6 ms
6,940 KB |
testcase_20 | AC | 11 ms
6,940 KB |
testcase_21 | AC | 4 ms
6,940 KB |
testcase_22 | AC | 3 ms
6,940 KB |
testcase_23 | AC | 8 ms
6,940 KB |
testcase_24 | AC | 14 ms
6,944 KB |
testcase_25 | AC | 1 ms
6,940 KB |
testcase_26 | AC | 13 ms
6,944 KB |
testcase_27 | WA | - |
testcase_28 | AC | 2 ms
6,944 KB |
testcase_29 | AC | 2 ms
6,944 KB |
testcase_30 | AC | 14 ms
6,940 KB |
testcase_31 | AC | 12 ms
6,940 KB |
testcase_32 | AC | 9 ms
6,944 KB |
testcase_33 | AC | 13 ms
6,940 KB |
testcase_34 | AC | 12 ms
6,940 KB |
testcase_35 | AC | 5 ms
6,948 KB |
testcase_36 | AC | 3 ms
6,940 KB |
testcase_37 | AC | 8 ms
6,940 KB |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:100:23: warning: 'ansj' may be used uninitialized [-Wmaybe-uninitialized] 100 | printf("%d %d\n",ansj,ansk); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:86:21: note: 'ansj' was declared here 86 | int ansj, ansk; | ^~~~ main.cpp:100:23: warning: 'ansk' may be used uninitialized [-Wmaybe-uninitialized] 100 | printf("%d %d\n",ansj,ansk); | ~~~~~~^~~~~~~~~~~~~~~~~~~~~ main.cpp:86:27: note: 'ansk' was declared here 86 | int ansj, ansk; | ^~~~ main.cpp:89:25: warning: 'ans_min' may be used uninitialized [-Wmaybe-uninitialized] 89 | if (ans_min == x[i]) { | ^~ main.cpp:65:21: note: 'ans_min' was declared here 65 | ll ans_max, ans_min; | ^~~~~~~ main.cpp:95:25: warning: 'ans_max' may be used uninitialized [-Wmaybe-uninitialized] 95 | if (ans_max == x[i]) { | ^~ main.cpp:65:12: note: 'ans_max' was declared here 65 | ll ans_max, ans_min; | ^~~~~~~
ソースコード
#include <sstream> #include <iostream> #include <algorithm> #include <deque> #include <string> using namespace std; typedef long long ll; ll x[100005]; ll maximum[100005]; ll maximum2[100005]; int main() { int N, D; ll K; scanf("%d %d %lld", &N, &D, &K); for (int i = 0; i < N; i++) { scanf("%lld", &x[i]); } deque<ll> nums; int cnt = 0; while (!nums.empty()) { nums.pop_back(); } for (int i = 0; i < N; i++) { while (!nums.empty() && x[i] > nums.back()) { nums.pop_back(); } nums.push_back(x[i]); if (i >= D && nums.front() == x[i - D]) { nums.pop_front(); } if (i >= D - 1) { maximum[cnt] = nums.front(); cnt++; } } int cnt2 = 0; ll ma = x[N - 1]; for (int i = N - 2;; i--) { if (cnt2 >= D+5 || i < 0) { break; } maximum2[i] = ma; ma = max(ma, x[i]); cnt2++; } ma = 0ll; ll ans_max, ans_min; for (int i = 0; i < cnt - 1; i++) { if (ma < maximum[i + 1] - x[i]) { ma = maximum[i + 1] - x[i]; ans_max = maximum[i + 1]; ans_min = x[i]; } } for (int i = cnt-1; i < N - 1; i++) { if (ma < maximum2[i] - x[i]) { ma = maximum2[i] - x[i]; ans_max = maximum2[i]; ans_min = x[i]; } } cout << ma*K << endl; if (ma != 0ll) { int ansj, ansk; for (int i = 0; i < N - 1; i++) { if (ans_min == x[i]) { ansj = i; break; } } for (int i = ansj + 1; i < N; i++) { if (ans_max == x[i]) { ansk = i; break; } } printf("%d %d\n",ansj,ansk); } return 0; }