結果

問題 No.409 ダイエット
ユーザー uenokuuenoku
提出日時 2017-02-15 11:41:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,710 bytes
コンパイル時間 1,000 ms
コンパイル使用メモリ 101,868 KB
実行使用メモリ 9,892 KB
最終ジャッジ日時 2023-08-28 17:08:46
合計ジャッジ時間 6,368 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
8,756 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,384 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 3 ms
4,376 KB
testcase_36 AC 3 ms
4,376 KB
testcase_37 AC 3 ms
4,380 KB
testcase_38 AC 3 ms
4,376 KB
testcase_39 AC 3 ms
4,380 KB
testcase_40 AC 4 ms
4,376 KB
testcase_41 AC 3 ms
4,380 KB
testcase_42 AC 3 ms
4,376 KB
testcase_43 AC 3 ms
4,376 KB
testcase_44 AC 3 ms
4,380 KB
testcase_45 AC 3 ms
4,380 KB
testcase_46 AC 3 ms
4,376 KB
testcase_47 AC 3 ms
4,376 KB
testcase_48 AC 3 ms
4,380 KB
testcase_49 AC 3 ms
4,380 KB
testcase_50 AC 3 ms
4,376 KB
testcase_51 AC 3 ms
4,376 KB
testcase_52 AC 3 ms
4,380 KB
testcase_53 AC 4 ms
4,376 KB
testcase_54 AC 3 ms
4,380 KB
testcase_55 AC 68 ms
4,456 KB
testcase_56 TLE -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
testcase_64 -- -
testcase_65 -- -
testcase_66 -- -
testcase_67 -- -
testcase_68 -- -
testcase_69 -- -
testcase_70 -- -
testcase_71 -- -
testcase_72 -- -
testcase_73 -- -
testcase_74 -- -
testcase_75 -- -
testcase_76 -- -
testcase_77 -- -
testcase_78 -- -
testcase_79 -- -
testcase_80 -- -
testcase_81 -- -
testcase_82 -- -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long int lli;
int main()
{
    lli a, b, n, w;
    cin >> n >> a >> b >> w;
    lli d[314514];
    rep(i, n) cin >> d[i];
    priority_queue<pair<lli, lli>, vector<pair<lli, lli>>, greater<pair<lli, lli>>> que;
    que.push(make_pair(0, d[0]));
    que.push(make_pair(1, b - a));
    for (int i = 1; i < n; i++) {
        set<int> s;
        map<lli, lli> mi;
        set<int> memo;
        while (!que.empty()) {
            auto j = que.top();
            que.pop();
            lli gain = j.second;
            int dep = j.first;
            //cout << "depth : " << dep << ' ' << gain << endl;
            s.insert(gain);
            auto itr = s.find(gain);

            if (itr != s.begin()) {
                s.erase(gain);
                continue;
            }
            if (memo.find(dep) != memo.end()) {
                mi[dep] = min(mi[dep], gain);
            } else {
                mi[dep] = gain;
                memo.insert(dep);
            }
        }
        for (auto j : mi) {
            que.push(make_pair(j.first + 1, j.second + (j.first + 1) * b - a));
            que.push(make_pair(0, j.second + d[i]));
        }
    }
    lli ans = 1e15;
    while (!que.empty()) {
        auto j = que.top();
        que.pop();
        ans = min(ans, j.second);
        int dep = j.first;
        lli gain = j.second;


        //cout << "depth : " << dep << ' ' << gain << endl;
    }
    cout << ans + w << endl;
}
0