結果

問題 No.505 カードの数式2
ユーザー nanophoto12nanophoto12
提出日時 2017-08-18 23:27:38
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,200 bytes
コンパイル時間 875 ms
コンパイル使用メモリ 96,064 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-22 15:55:30
合計ジャッジ時間 1,747 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 1 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
testcase_24 AC 2 ms
5,376 KB
testcase_25 AC 2 ms
5,376 KB
testcase_26 AC 1 ms
5,376 KB
testcase_27 AC 2 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cmath>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <iostream>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <cstdint>
#include <climits>
#include <unordered_set>
#include <sstream>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> t3;

using namespace std;

vector<ll> dp[2];

void update(int i, ll value)
{
    if(value >= 0)
    {
        dp[0][i+1] = max(dp[0][i+1], value);
    }
    else
    {
        dp[1][i+1] = min(dp[1][i+1], value);
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(int i = 0;i < n;i++)
    {
        cin >> v[i];
    }
    dp[0].assign(n+1, 0);
    dp[1].assign(n+1, 0);
    update(0, v[0]);
    for(int i = 1;i < n;i++)
    {
        for(int j = 0;j < 2;j++)
        {
            auto p = dp[j][i];
            update(i, p + v[i]);
            update(i, p - v[i]);
            update(i, p * v[i]);
            if(v[i] != 0)
            {
                update(i, p / v[i]);
            }
        }
    }
    cout << dp[0][n] << endl;
    return 0;
}
0