結果

問題 No.489 株に挑戦
ユーザー tatsukawa
提出日時 2017-02-25 19:44:48
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 1,091 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 166,008 KB
実行使用メモリ 10,240 KB
最終ジャッジ日時 2024-07-19 23:21:55
合計ジャッジ時間 3,415 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
#define get_variable_name(x) #x
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, begin, end) for(int (i) = (begin); (i) < (end); (i)++)
using namespace std;
using ll = int64_t;
struct compare {
bool operator() (const pair<ll, int> &l, const pair<ll, int>& r) const {
if(l.first > r.first) {
return l.second > r.second;
} else {
return false;
}
}
};
int main() {
ios::sync_with_stdio(false);
int j, k;
ll N, D, K, ans = 0;
cin >> N >> D >> K;
multiset<pair<ll,int>, compare> a;
vector<ll> x(N);
for(int i = 0; i < N; i++) {
cin >> x[i];
}
for(int i = 0; i < D; i++) {
a.insert({x[i],i});
}
for(int i = 0; i < N; i++) {
if(i+D < N) {
a.insert({x[i+D], i+D});
}
auto it = a.lower_bound({x[i], i});
a.erase(it);
pair<ll, int> l = {x[i], i};
if(a.size() == 0) break;;
auto r = *(a.begin());
int y = -l.first + r.first;
if (y > ans)
{
ans = y;
j = l.second;
k = r.second;
}
}
cout << ans * K << endl;
if (ans == 0)
return 0;
cout << j << ' ' << k << endl;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0