結果

問題 No.2321 Continuous Flip
ユーザー t98slidert98slider
提出日時 2023-05-27 06:39:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,040 bytes
コンパイル時間 2,986 ms
コンパイル使用メモリ 180,784 KB
実行使用メモリ 35,220 KB
最終ジャッジ日時 2023-08-26 17:15:52
合計ジャッジ時間 11,744 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 193 ms
28,396 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 186 ms
28,104 KB
testcase_22 WA -
testcase_23 AC 187 ms
28,192 KB
testcase_24 AC 97 ms
27,264 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 87 ms
25,140 KB
testcase_27 AC 87 ms
25,156 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 177 ms
35,132 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 174 ms
35,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, c, v, u, L, R;
    ll d, w;
    cin >> n >> m >> c;
    vector<vector<pair<int, ll>>> g(n + 1);
    vector<int> a(n);
    vector<ll> as(n + 1), dist(n + 1, 1ll << 60);
    for(int i = 0; i < n; i++){
        cin >> a[i];
        as[i + 1] = as[i] + a[i];
        g[i].emplace_back(i + 1, a[i]);
        g[i + 1].emplace_back(i, a[i]);
    }
    for(int i = 0; i < m; i++){
        cin >> L >> R;
        L--;
        g[L].emplace_back(R, c);
    }
    priority_queue<pair<ll,int>, vector<pair<ll,int>>, greater<pair<ll,int>>> pq;
    dist[0] = 0;
    pq.emplace(0, 0);
    while(!pq.empty()){
        tie(d, v) = pq.top();
        pq.pop();
        if(d > dist[v]) continue;
        for(auto &&pa : g[v]){
            tie(u, w) = pa;
            if(d + w >= dist[u]) continue;
            dist[u] = d + w;
            pq.emplace(dist[u], u);
        }
    }
    cout << as[n] - dist[n] << '\n';
}
0