結果
問題 | No.489 株に挑戦 |
ユーザー |
![]() |
提出日時 | 2018-10-09 23:58:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 39 ms / 1,000 ms |
コード長 | 1,426 bytes |
コンパイル時間 | 1,649 ms |
コンパイル使用メモリ | 105,116 KB |
実行使用メモリ | 6,360 KB |
最終ジャッジ日時 | 2024-07-20 00:11:32 |
合計ジャッジ時間 | 3,038 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include<iostream>#include <vector>#include <list>#include<stack>#include<queue>#include<array>#include <set>#include<map>#include<string>#include<stdlib.h>#include<algorithm>#include <functional>#include<math.h>#include<fstream>#include<iomanip>using namespace std;using ll = long long;using ld = long double;using pii = pair<int,int>;#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)#define REP(i,n) FOR((i),0,(n))#define WAITING(str) int str;std::cin>>str;#define DEBUGING(str) cout<<str<<endlconstexpr int INF = (1 << 30);constexpr ll INFL = (1ll << 60);constexpr ll MOD = 1000000007;// 10^9+7//�ϐ�ll N, D, K;vector<ll> x;//�v�Zvoid calc(){cin >> N >> D >> K;x.resize(N);REP(i, N) cin >> x[i];pair<ll, ll> res;ll best = -INF;using pll = pair<ll, ll>;using pqp = priority_queue<pll, vector<pll>, greater<pll>>;pqp pq;pq.push({ x[0],0 });FOR(i, 1, N) {while (pq.top().second < i - D)pq.pop();auto benefit = x[i] - pq.top().first;if (benefit > best) {best = benefit;res = { pq.top().second,i };}pq.push({ x[i],i });}if (best <= 0)cout << 0 << endl;else {cout << best * K << endl;cout << res.first << " " << res.second << endl;}}//�f�o�b�Ovoid debug(){int N;cin>>N;}//���C����int main(){calc();debug();return 0;}