結果

問題 No.489 株に挑戦
ユーザー noynotenoynote
提出日時 2017-02-24 23:13:07
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 1,025 bytes
コンパイル時間 1,224 ms
コンパイル使用メモリ 144,684 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-30 23:46:28
合計ジャッジ時間 6,633 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
4,380 KB
testcase_01 TLE -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 TLE -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:41:59: warning: ‘ans_day[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(dif * k > 0) cout << ans_day[0] << ' ' << ans_day[1] << endl;
                                                           ^
main.cpp:41:43: warning: ‘ans_day[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     if(dif * k > 0) cout << ans_day[0] << ' ' << ans_day[1] << endl;
                                           ^~~

ソースコード

diff #

#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int day1, day2;

int linerSearch(int a[100005], int i, int d, int n){
    int maxi = 0;
    range(j,i,min(i + d, n)){
        if(maxi < a[j]){
            day2 = j;
            maxi = a[j];
        }
    }
    return maxi - a[i];
}

int main(){
    int n, d, k;
    int a[100005];
    cin >> n >> d >> k;
    rep(i,n) cin >> a[i];
    d++;

    int ans_day[2];
    long long dif = 0;
    rep(i,n){
        int temp = linerSearch(a,i,d,n);
        if(temp > dif){
            dif = temp;
            ans_day[0] = i;
            ans_day[1] = day2;
        }
    }
    cout << dif * k << endl;
    if(dif * k > 0) cout << ans_day[0] << ' ' << ans_day[1] << endl;
}
0