結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-02-24 23:53:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 797 bytes |
| コンパイル時間 | 299 ms |
| コンパイル使用メモリ | 39,808 KB |
| 実行使用メモリ | 10,496 KB |
| 最終ジャッジ日時 | 2025-01-03 00:52:58 |
| 合計ジャッジ時間 | 19,435 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 TLE * 7 |
コンパイルメッセージ
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 = -1;
repeat (j,n) {
int acc = 0;
repeat_from (k,j,min(n,j+d+1)) acc = max(acc, x[k]);
if (mx < acc - x[j]) {
mx = acc - x[j];
mj = j;
}
}
int mk = -1;
repeat_from (k,mj,min(n,mj+d+1)) {
if (mx == x[k] - x[mj]) {
mk = k;
break;
}
}
printf("%lld\n", mx*(ll)K);
if (mx) printf("%d %d\n", mj, mk);
return 0;
}