結果
| 問題 | 
                            No.489 株に挑戦
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hornistyf
                         | 
                    
| 提出日時 | 2020-01-06 23:19:23 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 65 ms / 1,000 ms | 
| コード長 | 1,469 bytes | 
| コンパイル時間 | 899 ms | 
| コンパイル使用メモリ | 93,556 KB | 
| 実行使用メモリ | 7,552 KB | 
| 最終ジャッジ日時 | 2024-07-20 00:19:04 | 
| 合計ジャッジ時間 | 2,948 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 35 | 
ソースコード
//yuki489.cpp
//Mon Jan  6 22:44:48 2020
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<ll,ll> P;
ll nodenum;
P seg[400000];
void init(ll n){
	nodenum = 1;
	while (nodenum < n){
		nodenum*=2;
	}
	for (int i=0;i<nodenum*2-1;i++){
		seg[i] = make_pair(0,-1);
	}
}
P query(ll a, ll b, ll k, ll l, ll r){
	if (r<=a || b<=l){
		return make_pair(0,-1);
	}
	if (a<=l && r<=b){
		return seg[k];
	}else {
		P v1 = query(a,b,k*2+1,l,(l+r)/2);
		P v2 = query(a,b,k*2+2,(l+r)/2,r);
		if (v1.first>=v2.first){
			return v1;
		}else {
			return v2;
		}
	}
}
int main(){
	ll n,d,k;
	cin >> n >> d >> k;
	init(n);
	for (ll i=0;i<n;i++){
		ll temp;
		cin >> temp;
		seg[nodenum-1+i] = make_pair(temp,i);
	}
	for (ll i=nodenum-2;i>=0;i--){
		if (seg[2*i+1].first>=seg[2*i+2].first){
			seg[i] = seg[2*i+1];
		}else {
			seg[i] = seg[2*i+2];
		}
	}
	P ans = make_pair(0,-1);
	ll ansindex = -1;
	for (ll i=0;i<n;i++){
		ll last = min(i+d,n-1);
		P temp = query(i,i+d+1,0,0,nodenum);
		ll x = temp.first-seg[nodenum-1+i].first;
		if (ans.first<x){
			ans.first = x;
			ans.second = temp.second;
			ansindex = i;
		}
	}
	cout << ans.first*k << endl;
	if (ansindex>=0){
		cout << ansindex << " " << ans.second << endl;
	}
//	printf("%.4f\n",ans);
}
            
            
            
        
            
hornistyf