結果

問題 No.489 株に挑戦
ユーザー mamekinmamekin
提出日時 2017-04-02 04:27:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,055 bytes
コンパイル時間 1,215 ms
コンパイル使用メモリ 108,168 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-07-07 20:11:07
合計ジャッジ時間 3,838 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 19 WA * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:52:29: warning: 'b' may be used uninitialized [-Wmaybe-uninitialized]
   52 |         cout << a << ' ' << b << endl;
      |                             ^
main.cpp:35:12: note: 'b' was declared here
   35 |     int a, b;
      |            ^
main.cpp:52:22: warning: 'a' may be used uninitialized [-Wmaybe-uninitialized]
   52 |         cout << a << ' ' << b << endl;
      |                      ^~~
main.cpp:35:9: note: 'a' was declared here
   35 |     int a, b;
      |         ^

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int n, d, k;
    cin >> n >> d >> k;
    vector<int> x(n);
    for(int i=0; i<n; ++i)
        cin >> x[i];

    int ans = 0;
    int a, b;
    multiset<pair<int, int> > ms;
    for(int i=0; i<n; ++i){
        ms.insert(make_pair(x[i], i));
        pair<int, int> p = *ms.begin();
        if(ans < x[i] - p.first){
            ans = x[i] - p.first;
            a = p.second;
            b = i;
        }
        if(i-d >= 0)
            ms.erase(make_pair(x[i-d], i-d));
    }

    ans *= k;
    cout << ans << endl;
    if(ans > 0)
        cout << a << ' ' << b << endl;

    return 0;
}
0