結果
| 問題 |
No.489 株に挑戦
|
| コンテスト | |
| ユーザー |
alpha_virginis
|
| 提出日時 | 2017-03-12 15:55:07 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,694 bytes |
| コンパイル時間 | 1,878 ms |
| コンパイル使用メモリ | 177,184 KB |
| 実行使用メモリ | 7,524 KB |
| 最終ジャッジ日時 | 2024-06-30 00:27:03 |
| 合計ジャッジ時間 | 3,214 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 7 |
ソースコード
#include <bits/stdc++.h>
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpi(x1) fprintf(stderr, "#%s.%d (%s) = (%d)\n", __func__, __LINE__, #x1, x1);
#define dumpii(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%d, %d)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpiii(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%d, %d, %d)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
struct S002 {
int n;
S002& operator > (long& x) {
n = x;
return *this;
}
S002& operator >= (long& x) {
if( scanf("%ld", &x) <= 0 ) exit(0);
return *this;
}
S002& operator >= (double& x) {
if( scanf("%lf", &x) <= 0 ) exit(0);
return *this;
}
S002& operator >= (std::string& s) {
if( not (std::cin >> s) ) exit(0);
return *this;
}
template<typename a>
S002& operator >= (std::vector<a>& v) {
v.resize(n);
for(long i = 0; i < n; ++i) {
*this >= v[i];
}
return *this;
}
};
template<typename a>
struct S003 {
std::vector<a> ys;
S003(std::vector<a> xs, long k) {
long n = xs.size();
ys.resize(n - k + 1);
std::deque<a> q;
for(long i = 0; i < n; ++i) {
while( not q.empty() and xs[q.back()] >= xs[i]) q.pop_back();
q.push_back(i);
long w = i - k + 1;
if( w >= 0 ) {
ys[w] = xs[q.front()];
if( q.front() == w ) q.pop_front();
}
}
}
};
struct Solver {
long n, d, k;
std::vector<long> xs;
Solver() {
S002 r;
r >= n >= d >= k >n>= xs;
}
void solve() {
std::vector<long> ys;
std::transform(xs.begin(), xs.end(), std::back_inserter(ys),
[](long x){ return -x; });
S003<long> s(ys, d + 1);
std::vector<long> zs;
for(int i = 0; i < (int)s.ys.size(); ++i) {
zs.push_back((-s.ys[i]) - xs[i]);
}
long max = *std::max_element(zs.begin(), zs.end());
auto it = std::find(zs.begin(), zs.end(), max);
long x = it - zs.begin();
auto it2 = std::find(xs.begin() + x, xs.end(), xs[x] + max);
long y = it2 - xs.begin();
if( max * k == 0 ) {
puts("0");
return;
}
printf("%ld\n", max * k);
printf("%ld %ld\n", x, y);
}
};
int main() {
for(;;) {
std::unique_ptr<Solver> s(new Solver());
s->solve();
}
return 0;
}
alpha_virginis