結果
問題 | No.489 株に挑戦 |
ユーザー | tekitouk |
提出日時 | 2017-02-25 19:14:04 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,459 bytes |
コンパイル時間 | 818 ms |
コンパイル使用メモリ | 75,664 KB |
実行使用メモリ | 5,888 KB |
最終ジャッジ日時 | 2024-06-11 15:00:29 |
合計ジャッジ時間 | 2,283 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 8 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | WA | - |
testcase_16 | AC | 11 ms
5,376 KB |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 6 ms
5,376 KB |
testcase_20 | AC | 12 ms
5,376 KB |
testcase_21 | AC | 5 ms
5,376 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 8 ms
5,376 KB |
testcase_24 | AC | 13 ms
5,376 KB |
testcase_25 | AC | 2 ms
5,376 KB |
testcase_26 | AC | 13 ms
5,888 KB |
testcase_27 | WA | - |
testcase_28 | AC | 1 ms
5,376 KB |
testcase_29 | AC | 2 ms
5,376 KB |
testcase_30 | AC | 14 ms
5,376 KB |
testcase_31 | AC | 12 ms
5,376 KB |
testcase_32 | AC | 8 ms
5,376 KB |
testcase_33 | AC | 12 ms
5,376 KB |
testcase_34 | AC | 12 ms
5,376 KB |
testcase_35 | AC | 5 ms
5,376 KB |
testcase_36 | AC | 4 ms
5,376 KB |
testcase_37 | AC | 8 ms
5,376 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); D++; 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 - 1) { break; } maximum2[i] = ma; ma = max(ma, x[i]); cnt2++; } ma = 0ll; ll ans_max, ans_min; for (int i = 0; i < cnt; i++) { if (ma < maximum[i] - x[i]) { ma = maximum[i] - x[i]; ans_max = maximum[i]; ans_min = x[i]; } } for (int i = cnt; 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 = 0; i < N; i++) { if (ans_max == x[i]) { ansk = i; break; } } printf("%d %d\n",ansj,ansk); } return 0; }