結果
問題 |
No.489 株に挑戦
|
ユーザー |
|
提出日時 | 2017-02-24 23:44:33 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 669 bytes |
コンパイル時間 | 380 ms |
コンパイル使用メモリ | 39,680 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-01-03 00:44:23 |
合計ジャッジ時間 | 22,627 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 TLE * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | int n, d, K; scanf("%d%d%d", &n, &d, &K); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~ main.cpp:11:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 11 | repeat (i,n) scanf("%d", &x[i]); | ~~~~~^~~~~~~~~~~~~
ソースコード
#include <cstdio> #include <algorithm> #define repeat(i,n) for (int i = 0; (i) < int(n); ++(i)) #define repeat_from(i,m,n) for (int i = (m); (i) < int(n); ++(i)) using ll = long long; using namespace std; constexpr int MAX_N = 1e5; int x[MAX_N]; int main() { int n, d, K; scanf("%d%d%d", &n, &d, &K); repeat (i,n) scanf("%d", &x[i]); int mx = 0, mj = 0, mk = 0; repeat (j,n) { repeat_from (k,j,min(n,j+d+1)) { if (mx < x[k] - x[j]) { mx = x[k] - x[j]; mj = j; mk = k; } } } printf("%lld\n", mx*(ll)K); if (mx) printf("%d %d\n", mj, mk); return 0; }